bash_notes
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
bash_notes [2022/04/06 22:25] – [list file names within a specific range] raju | bash_notes [2023/12/28 08:49] (current) – [other pages in this wiki] raju | ||
---|---|---|---|
Line 1: | Line 1: | ||
===== tasks ===== | ===== tasks ===== | ||
- | ==== list file names within a specific range ==== | + | ==== dummy ==== |
- | Q: Given a set of files in a directory: | + | * [[list files within a specific range]] |
- | < | + | |
- | file1.txt | + | |
- | file2.txt | + | |
- | ... | + | |
- | file30.txt | + | |
- | ... | + | |
- | </ | + | |
- | how do I list files within a specific range, say 18 through 31? | + | |
- | A: | + | ===== dummy ===== |
+ | ==== other pages in this wiki ==== | ||
+ | * [[bash scripting]] | ||
+ | * [[shell scripting notes]] | ||
+ | |||
+ | ==== useful links ==== | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * http:// | ||
+ | |||
+ | ==== documentation links ==== | ||
+ | * ignoredups, erasedups - https:// | ||
+ | |||
+ | ==== what is the difference between "ls > dirlist 2>& | ||
+ | The command | ||
< | < | ||
- | ls file{18..31}.txt | + | ls > dirlist 2>&1 |
</ | </ | ||
- | + | directs both standard output (file descriptor 1) and standard error (file descriptor 2) to the file dirlist, while the command | |
- | To run a command on each of them, use a for loop | + | |
< | < | ||
- | for file in file{18..31}.txt | + | ls 2>&1 > dirlist |
- | ... | + | |
</ | </ | ||
+ | directs only the standard output to file dirlist, because the standard error was made a copy of the standard output before the standard output was redirected to dirlist. | ||
- | This construct is known as a " | + | To conclude, the order of redirections |
- | Ref: | + | Ref:- https:// |
- | * https:// | + | |
- | * https:// | + | |
- | tags | list file names with a range | ||
- | |||
- | ===== dummy ===== | ||
- | ==== useful links ==== | ||
- | * https:// | ||
===== getopts ===== | ===== getopts ===== | ||
==== useful articles ==== | ==== useful articles ==== |
bash_notes.1649283951.txt.gz · Last modified: 2022/04/06 22:25 by raju