awk, print special character, how?
Hello,
Trying to figure out how to append the wildcard character * to each entry of the first column of a data file. I've tried various combinations of quotes and backslashes, but it just doesn't want to work for me. Code:
awk '{print $1"*"}' somefile |
Quote:
Code:
awk '{$1=$1"*"; print}' somefile |
Thanks for that. I just wanted to extract the first column but to tag * onto each entry from that column.
Code:
awk '{$1=$1"*"; print $1}' somefile Appreciate your help. |
How bizarre.... is that a MacOS thing? The original version of
yours works just fine here. Code:
awk -F: '{print $1"*"}' /etc/passwd Cheers, Tink |
I thought that was where the problem lay as I was getting a
Code:
set: No match Turns out I had to add Code:
set nonomatch Code:
set list = `ls -l $dir/D*bp03 | awk '{print $9}' | awk 'BEGIN {FS="."} {print $2}' | awk 'BEGIN {ORS=" "} {print "D*"$0".Z"}'` Code:
set nonomatch |
"$1" prints only the first column, and he apparently wants all of the columns in the output.
Edit: just read the above more closely. :doh: Let this be a lesson. Don't just say "it doesn't work" and leave everyone to guess what you mean. Explain exactly why it isn't working, and how it should work. Preferably with actual examples of input and output. Anyway, if the number of columns is fixed and manageable, you could also simply include them in the print statement. Code:
awk '{ print $1"*",$2,$3,$4,$5 }' somefile |
Code:
set list = `ls -l $dir/D*bp03 | awk '{print $9}' | awk 'BEGIN {FS="."} {print $2}' | awk 'BEGIN {ORS=" "} {print "D*"$0".Z"}'` |
All times are GMT -5. The time now is 09:46 PM. |