Skip to content

Instantly share code, notes, and snippets.

@Gyumeijie
Last active January 30, 2018 09:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gyumeijie/c36f34c71f0dc94a4685e1eea148f563 to your computer and use it in GitHub Desktop.
Save Gyumeijie/c36f34c71f0dc94a4685e1eea148f563 to your computer and use it in GitHub Desktop.
The command line arg V.S The standard input of a command
In most case, if a command takes a file name as a command line arg, we can also use the content of
the file as the standard input of a command, the two ways have the same effect.
For example, a directory contains the following files:
example1.txt
example2.txt
example3.txt
example4.txt
example5.txt
example6.txt
example7.txt
example8.txt
example9.txt
example10.txt
What we wanna do is to remove the suffix of all file, we can use command `cut -f1 -d'.' <<<$(ls *.*)` ;
The other is to store the filename list in a temprary file, eg tempfile, then we use `cut -f1 -d'.' tempfile`.
The former way is provide a string containing the file list as the cut's standard input, and the latter
one is to provide a file which contains the file list as it's command line arg.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment