Note that according to the standards, setting FS to an empty string produces undefined results. (Doing so treats each character as a field in gawk and some other version of awk, but generates various errors or unexpected results on other versions of awk.) If I understand what shivacoder is trying to do, I think the following is a portable way to do what was requested:
Last edited by Don Cragun; 11-26-2012 at 01:18 AM..
Hi, I have recently posted in another thread started by me :D. But in an effort to make my script more beautiful I've been thinking abbout while loops.
I run my script with the command:
sh script 4 numbers.txt
And my script is like this:
data=`cat $2 | xargs -n $1`
#echo $data
... (13 Replies)
I have a four part number
eg: 1.21.1.3
I need to find a way in shell script to decrement this by one and put in a loop
so the values printed will be
1.21.1.2
1.21.1.1
1.21.1.0
Which is the best way to do this in shell script?? (7 Replies)
I have two files which I would like to compare and then manipulate in a way.
File1:
pictures.txt 1.1 1.3
dance.txt 1.2 1.4
treehouse.txt 1.3 1.5
File2:
pictures.txt 1.5 ref2313 1.4 ref2345 1.3 ref5432 1.2 ref4244
dance.txt 1.6 ref2342 1.5 ref2352 1.4 ref0695 1.3 ref5738 1.2... (1 Reply)
Hi all,
Thanks in Advance!
I want a simple script to print today and yesterdays date.
using this command
date +%d%m%Y
i can able get today's date but i want yesterday's date with the same format.
so i tried using simple decrement operator
but... (2 Replies)
Hi,
I need a script that will subtract 1 from the third column of the line beginning with %, leaving all other values the same. So 158 should be 157, 308 should be 307, 458 should be 457.
Before:
# 30109 xyz abc Data
% 30109 158 5 8 2
000023f
01f4145
# 30109 ... (3 Replies)
Hi, everyone!
I have a file, when I print its $1 out it show several strings like this:
AABBCC
AEFJKLFG
FALEF
FAIWEHF
What I want to do is that, after output of each record, search the string in all files in the same folder, print out the record and file name.
This is what I want... (4 Replies)
Hi All,
I am new to AWK programming. I have the following for loop in my awk program.
cat printhtml.awk:
BEGIN
-------- <some code here>
END{
----------<some code here>
for(N=0; N<H; N++)
{
for(M=5; M<D; M++) print "\t" D "";
}
-----
}
... (2 Replies)
Hello,
I have an input file that looks like so:
1 2 3
4 5 6
7 8 9
and I just want to print the first and third column (note: my actual file contains many many more fields so I don't want to use '{ print $NF }' for each field I want.
I tried using:
awk 'BEGIN {FS=" "} { for (i=1;... (13 Replies)