Get the file name in Ubuntu and generate the list txt

Source: Internet
Author: User

To test the Caffe, prepare a bunch of picture preparation tests. Before the operation was prepared for renaming, it is now necessary to read the file name all out to generate txt as a label to use. This procedure uses the Find command and the SED command.

Look first.

Of course, there is a follow-up process, that is, after all the file names tagged serial number, this is the role of the SED command, here I also made the sh file, convenient to use, the code as follows, self-reference modification use it.

$path$train_file#‘s/pattern/your_word/g‘ file_path/filename‘s/$/ 6/g‘$train_file

1. Find command:
Find is followed by an address that holds the file you want to find, followed by the-name parameter, followed by a parameter representing the file name *.jpg that represents all the JPG files.
The ' > ' symbol represents output to a file, which is output to a TXT file.

2. SED command:
-I means directly modifying the contents of the read file, not the output to the terminal
The content in the quotation marks represents the substitution, the $ represents at the end of the file, followed by a space and a number representing each line of characters followed by a space and a number, representing the file corresponding to the label ordinal

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Get the file name in Ubuntu and generate the list txt

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.