11-25-2012
Quote:
Originally Posted by
shivacoder
Can i have another loop for 'c' inside this loop - to decrement it: --d till d=1?
Of course. Probably there are some limits to nesting loops, but i have to encounter them yet.
Quote:
Do you think AWK is OK for that task?
Absolutely. You could do the same in other languages too (perl, shell, python, ruby, ...), but it probably would gain you nothing. If you feel comfortable with awk (and it seems that you do) then, by all means, go with it!
I hope this helps.
bakunin
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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)
Discussion started by: baghera
13 Replies
2. Shell Programming and Scripting
export a=`date`
a=`expr $a + 1`
Is it possible?
if not how can i increment or decrement a date variable? (2 Replies)
Discussion started by: arghya_owen
2 Replies
3. Shell Programming and Scripting
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)
Discussion started by: codeman007
7 Replies
4. Shell Programming and Scripting
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)
Discussion started by: linuxkid
1 Replies
5. Shell Programming and Scripting
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)
Discussion started by: anishkumarv
2 Replies
6. Shell Programming and Scripting
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)
Discussion started by: morrbie
3 Replies
7. Shell Programming and Scripting
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)
Discussion started by: xshang
4 Replies
8. Shell Programming and Scripting
Here's my code:
awk -F '' 'NR==FNR {
if (/time/ && $5>10)
A=$2" "$3":"$4":"($5-01)
else if (/time/ && $5<01)
A=$2" "$3":"$4-01":"(59-$5)
else if (/time/ && $5<=10)
A=$2" "$3":"$4":0"($5-01)
else if (/close/) {
B=0
n1=n2;
... (2 Replies)
Discussion started by: klane
2 Replies
9. Shell Programming and Scripting
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)
Discussion started by: ctrld
2 Replies
10. Shell Programming and Scripting
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)
Discussion started by: Rabu
13 Replies