-
Notifications
You must be signed in to change notification settings - Fork 0
3. Batch Operations
gitarunprasanna83 edited this page Jul 23, 2019
·
9 revisions
By now, you know how to use commands to complete an operation on text files, combine two or more commands using PIPES. In this exercise, you will learn how to make executable files in simple bash script
- Open a textpad and type the following lines below

- Save as .. bashscript1.sh
** Line 5, shows the same one-liner that we created using pipe in File operations section **
- In terminal type -- > bash bashscript1.sh
Execute it and see the output..

Combine group of commands to execute one line at a time, process repeated operations with multiple files in a loop. For this task, some practice on wild cards is essential !
- Make a directory “WildCards”
- Enter inside the directory
touch {1..3}.txttouch {a..c}.txttouch cat_{001..002}.txttouch rat_{10,20,30}_{a,b,c}.txt-
touch AA.txt[How many files you have in total ? ls | wc -l] - Display txt files with only one character that is number -- >
ls [0-9].txt - Display txt files with only one character that is a letter -- >
ls [a-z].txt - Display txt files with only one character that is a letter or word -- >
ls ?.txt[pipe with wc -l to check total number of files in this category] - Display txt files not starting with a capital letter -- >
ls [!A-Z]*.txt - Display txt files ending with an alphabet -- >
ls *_[a-z].txt - Display file that have 10 in between their names -- >
ls *10*.txt
Creating a batch file
Submitting a batch job
Opening a slurm job
Submitting a slurm job
Creating a pipe-line with slurm