Skip to content
Advertisement

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.sortedByCoord.out.bam)). The 6900_STARtmp contain further subfolders but I don’t want to change name of sub folders present in 6900_STARtmp. Please see the image I want to remove 6900 from

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 < 1.tmp for line incat 1.tmp;

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://mywiki.wooledge.org/BashFAQ/001 I would do this, with a

redirect and print script output using for loop and awk in linux

I have a script which give out put like this : my_script <variables> output like this : now I want to redirect the output and print like this print “some_text col_3@col_4 some_more_text col_4” ans will be like this: some_text textext3@texxt6 some_more_text texxt6 some_text textext1@text4 some_more_text text4 some_text text5@textxt0 some_more_text textxt0 ….. so on col_3 = all values in column 3,

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

Advertisement