Help me to understand.
Searches for a text file with the fewest words.
$ find -name "*txt" | xargs wc -w | sort -g | head -n 1 How to display the contents of the found text file with numbered lines? cat -n ?
Help me to understand.
Searches for a text file with the fewest words.
$ find -name "*txt" | xargs wc -w | sort -g | head -n 1 How to display the contents of the found text file with numbered lines? cat -n ?
options for issuing the contents of a file or stream with numbered lines:
nl
the contents of the specified file:
$ nl ΡΠ°ΠΉΠ» the contents of the stream of lines:
$ ΠΊΠ°ΠΊΠΈΠ΅-ΡΠΎ ΠΊΠΎΠΌΠ°Π½Π΄Ρ | nl cat
the contents of the specified file:
$ cat -n ΡΠ°ΠΉΠ» the contents of the stream of lines:
$ ΠΊΠ°ΠΊΠΈΠ΅-ΡΠΎ ΠΊΠΎΠΌΠ°Π½Π΄Ρ | cat -n less
the contents of the specified file:
$ less -N ΡΠ°ΠΉΠ» the contents of the stream of lines:
$ ΠΊΠ°ΠΊΠΈΠ΅-ΡΠΎ ΠΊΠΎΠΌΠ°Π½Π΄Ρ | less -N awk
the contents of the specified file:
$ awk '{ print FNR " " $0 }' ΡΠ°ΠΉΠ» the contents of the stream of lines:
$ ΠΊΠ°ΠΊΠΈΠ΅-ΡΠΎ ΠΊΠΎΠΌΠ°Π½Π΄Ρ | awk '{ print FNR " " $0 }' perl
the contents of the specified file:
$ perl -pe '$_ = "$. $_"' ΡΠ°ΠΉΠ» the contents of the stream of lines:
$ ΠΊΠ°ΠΊΠΈΠ΅-ΡΠΎ ΠΊΠΎΠΌΠ°Π½Π΄Ρ | perl -pe '$_ = "$. $_"' you, as I understand it, the whole stream ends with the issuance of the file name . To apply any of the listed commands to it, you need to use the xargs program, which you have already used. for example, you can pass this name to the nl program like this:
$ ΠΊΠΎΠΌΠ°Π½Π΄Ρ Π²ΠΎΠ·Π²ΡΠ°ΡΠ°ΡΡΠΈΠ΅ ΠΈΠΌΡ ΡΠ°ΠΉΠ»Π° | xargs nl Source: https://ru.stackoverflow.com/questions/594476/
All Articles