03-04-2020
Problem with awk print
Hello,
I have a file like
Quote:
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,fifteen
When I try to print all strings
Quote:
while read string
do
var=$(echo $string | awk -F"," '{print $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15}')
set -- $var
newstr=$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15
echo $newstr
echo $newstr >> output.txt
done < test.dat
I get that output
Quote:
one,two,three,four,five,six,seven,eight,nine,one0,one1,one2,one3,one4,one5
How can I get
Quote:
ten,eleven,twelve,thirteen,fourteen,fifteen
Could you please help. Thanks !
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Using Sun OS5.1 - i am able to lp as root but not as a user.
Let me know what you think.
Mark (2 Replies)
Discussion started by: Mark Duncan
2 Replies
2. AIX
Hi,
I've configured a print queue in Unix AIX 5.2 and it is duplex print queue. If I issue a print here it is not printing in the remote site. i.e If I'm issuing a print from India to print in the printer located in the Datacentre Taiwan, user replying that they're not receiving any print out.... (1 Reply)
Discussion started by: Vijay11
1 Replies
3. Shell Programming and Scripting
The line is simple, use " '{ print $1"]"$2"\"$3THE " NEEDS TO GO HERE$4 }'
I've tried \", "\, ^" and '"" but none of it works. What am I missing? Putting in the [ between $1 and $2 works fine, I just need to do the same with a ".
Thanks. (2 Replies)
Discussion started by: LordJezo
2 Replies
4. HP-UX
Hi,
Could any one please let me know what is the option
available in UNIX to print by specifying the paper size?
We are using Unix11i. I could n't see any option specified in the 'lp' command to print the report by specifying the size of the paper. It would be of great help to me, if... (1 Reply)
Discussion started by: ukarthik
1 Replies
5. Shell Programming and Scripting
Actually I got a list of file end with *.txt
I want to use the same command apply to all the *.txt
Thus I try to find out the fastest way to write those same command in a script and then want to let them run automatics.
For example:
I got the file below:
file1.txt
file2.txt
file3.txt... (4 Replies)
Discussion started by: patrick87
4 Replies
6. Homework & Coursework Questions
My Script:
#!/bin/sh
date=`date +%y%m%d -d"1 day ago"`
in_dir=/vis/logfiles/to_solmis
cp `grep -il ST~856~ $inbound_dir/*$date*` /vis/sumit/in_ASN/
for i in /vis/sumit/in_ASN/*
do
mkdir -p /vis/sumit/inboundasns.$date
cp `echo $i`... (1 Reply)
Discussion started by: shrima.pratima
1 Replies
7. Shell Programming and Scripting
Hello,
I have a file seperated with "|" I want to search the 11th field if it matches certain words change it to an empty space.
I have managed to do that, but now I need it to replace the file.
this is my code:
awk 'BEGIN{OFS=FS="|"}$11=="to... (9 Replies)
Discussion started by: TasosARISFC
9 Replies
8. Shell Programming and Scripting
Hi,
My input files is like this
axis1 0 1 10
axis2 0 1 5
axis1 1 2 -4
axis2 2 3 -3
axis1 3 4 5
axis2 3 4 -1
axis1 4 5 -6
axis2 4 5 1
Now, these are my following tasks
1. Print a first column for every two rows that has the same value followed by a string.
2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies
9. Shell Programming and Scripting
Hi,
I have the following input in a file & need output as mentioned below(need counter of every occurance of field which is to be increased by 1).
Input:
919143110065
919143110065
919143110052
918648846132
919143110012
918648873782
919143110152
919143110152
919143110152... (2 Replies)
Discussion started by: siramitsharma
2 Replies
10. Shell Programming and Scripting
Hello friends,
I have written a script and i need to add some part into it so that i could print out more results depending on more conditions,
This is the core part of the script which does the actual work:
echo "$j" && nawk -v stat=$2 'NR==FNR &&... (1 Reply)
Discussion started by: EAGL€
1 Replies