Removes two words: "_scATAC_hg19_noDup_noMT.bam" and "/directory/to/singleCell/" (all occurrences) from bamlist.txt
Then it replaces all occurrences of "/" with a tab ("\t")
It prints second column, from the output from step2, and I think output field separator is not necessary here.
Collapses all the lines from output from 3 , into a row with tab separated values.
I think -e 's/\/directory\/to\/singleCell\///g' bamlist.txt | sed -e 's/\//\t/g' | awk 'OFS="\t"{print $2}' | tr '\n' '\t' is not necessary to be complex and a simple code may get the same result. Please post few lines from bamlist.txt
Not answer but I wanted to point out that in a sed script the pattern and replacement do not need to be separated by /. (Almost) any character will do which is useful to make scripts more readable. E.g.
echo "foo/bar/spam" | sed 's/\/bar\//\/eggs\//'
is more readable in this case if you use | as separator:
Oh, I see it now...! He uses %. I don't mind deleting my answer/comment but I think it's useful to have it explicitly stated since I have seen (and done) a lot of /-escaping mess before realizing this! I would suggest Pierre to add a note to his answer about it.
typo there
I thought carriage return is
\r
.a yes, thank, I'll fix it.