[Linux operations] awk operation print Picture path

Source: Internet
Author: User

Recently a small operation has to be done on Linux:

is to print the path of all pictures in a folder and the corresponding file name to a TXT file, forming a list-like thing.

First, here's a command to know: awk

Awk is actually a powerful text analysis tool that reads the file line-by-row (awk is processing each line), slices each row with a space as the default delimiter, and then makes various analytical processing of the cut.

Specific Use method:

' {pattern + action} ' {Filenames}


Back to my question, that's how it's done:

First go to the folder directory I want to work with,

Then typed the following command:

Here, "Train" is the folder I want to work with (all pictures inside), "| "This symbol is a pipe, inside the single quotation mark, the first thing that follows in curly braces can be referred to as" condition ", followed by an absolute path, and a double quote followed by" $ "means that all columns in this row are processed.

PS: If $ $ represents the first column, and so on.

And then we'll see what's inside of 1.txt.

At this point, we successfully print out the absolute path of all the pictures in the folder ~

[Linux operations] awk operation print Picture path

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.