Reputation: 258
I have this command line:
while read line
do
echo $line >> Ho
grep -c "0/1/0" file_$line\.hwe >> Ho
done < my_file
Which will give me something like that:
ID1
689
ID2
747
etc.
I was wondering how I can make the loop so that the ls and grep command print on the same line instead of different lines. Here is what I want to obtain:
ID1 689
ID2 747
etc.
Any clue? Thanks!
M
Upvotes: 0
Views: 25
Reputation: 141493
Really, just:
while IFS= read -r line; do
echo "$line"$'\t'"$(grep -c "0/1/0" "file_$line.hwe")"
done < my_file >> Ho
or maybe:
while IFS= read -r line; do
printf "%s\t%s\n" "$line" "$(grep -c "0/1/0" "file_$line.hwe")"
done < my_file >> Ho
But still you could:
while IFS= read -r line; do
echo "$line"
grep -c "0/1/0" "file_$line.hwe"
done < my_file |
paste -d $'\t' - - >> Ho
Upvotes: 1