Entering edit mode
6.1 years ago
bk11
★
3.0k
Hi
I wrote a bash script with awk and sed commands in it to parse text files in a directory. This script runs without giving any output. What is wrong with it?
#!/bin/bash
for i in *.txt; do
awk -F'\t' '{print $16}' $i | sed '1d' | tr -d '\r' >$i_get_signals.sh
done
We need more information. What does your input data look like? What output do you expect? Are you running the script while you're in the directory that the
.txt
files are in? How are you invoking the script?You will also need to tell us why this is a bioinformatics question and not just a programming question else we may close it as off topic.
Yes I am running the script in the same directory that has the text files. This is related to bioinformatics as it is used to get URL to download histone proteins binding signals from different cell types.
It is related to bioinformatics, but only borderline. It is essentially just unix text processing, and there are more specialised forums for this. We usually tolerate posts like this as we understand that these are common problems in bioinformatics, but it's not pure bioinformatics.
Why do you send the result to a
.sh
file?I tried sending the result to .txt file but also it did not work.
It shouldn't make a difference, but with the extension
.sh
you suggest this is a shell script.That is because OP is using *.txt in loop and doesn't want output with .txt for obvious reasons. Instead OP could have used any other extension instead of sh (.out, .text, .file etc or without extension). WouterDeCoster
Yeah, of course, and while file extensions have almost no meaning in unix it is quite confusing to use something unexpected.