Skip to content

Tag: for-loop

Remove part of file name in multiple sub directories

The main folder “Main” contains multiple subfolders (6900,159, 9997, …) and each subfolder contains 8 items (4 files (6900Log.final.out, 6900Log.out, 6900Log.progress.out, 6900SJ.out.tab), 3 folders (6900_STARgenome, 6900_STARpass1, 6900_STARtmp), and one compressed file (6900Aligned.sortedB…

Bash loop only read the last line

I have problems trying to extract data behind colons in multiple lines using while loop and awk. This is my data structure: What I want to get is the BioSample ID, which is like SAMD00019077. Scripts I tried: while read line ; do echo $line | awk -F’:’ ‘{print $3}’ > 1.tmp2 ; done &…

using for in loop with sql output

I have a roles.txt file that contains SELECT ROLE_NAME FROM SENTRY_ROLE WHERE ROLE_NAME produces: Im trying to echo all the roles from roles.txt that are not in the sql_output (user in this example). This is what i have so far: Answer That’s not how you iterate over the lines of a file. See http://mywik…

for loop syntax with grep in bash

I want to do text processing for lines in file.txt that ends with 0, I wrote an easy form of it to ask my question clearly. I want the output to be: 1 343 4352 0 432 432 2345 0 I want $i variable to be “1 343 4352 0” and after that to be “432 432 2345 0” but