Hello guys,
I'm stuck with AWK and probably stupid stuff.
I've a file with some values like:
Then, extracting these vaues from that file is quite simple:
This will show: 456
Now, what I don't realize is how to do a sequentially extraction using the for cycle:
The above string is not correct since I receive an error (awk: line 1: syntax error at or near {)
Could someone help me to understand how extracting all values using a for and a position variable ??
Thanks!
Last edited by Scott; 10-23-2010 at 11:46 PM..
Reason: Please use code tags
OmG! Searching for the third time on forum give me a solution!
Sorry, first to post I searched without find anythig!
Well, the solution is:
---------- Post updated at 06:48 PM ---------- Previous update was at 06:40 PM ----------
Thanks for reply ctsgnb, I already know that $0 mean the whole row, but I need to analyze values one by one, and for sure I remove some code from "for cycle"!
Btw, this is another approach:
And it was apreciated!
But if I want only some positions (e.g. 1, 3 and 5) I think the better way will be the cycle (ok here we have only 5 values, but in the real row I have 48 values!!!)
Last edited by Scott; 10-23-2010 at 11:46 PM..
Reason: Code tags
Input data as below (filetest.txt):
1|22 JAN Minimum Bal 20.00 | SAT
2|09 FEB Extract bal 168.00BR | REM
3|MIN BAL | LEX
Output should be:
( If there is Date & Month in 2nd field of Input file, It should be seperated else blank. If There is Decimal OR Decimal & Currency in last of the 2nd... (7 Replies)
i have a requirement like this
if the line contains from position 294 to 299 is equal to "prabhu" ,then print entire line .
i want to use awk
awk '{if(substr(294-299) == 'prabhu') print "line" }' filename (1 Reply)
Hi,
Anybody knows how to get the value after the regexp and test it on pattern? The if the pattern matches, it will print the entire line on a separate file.
Here's my raw file:
^_Name^_string^_Apple ^_Color^_string^_Red ^_Code^_string^_121
^_Name^_string^_Banana ^_Code^_string^_123 ... (7 Replies)
Hi Guys!
Could anyone help me with?..
I have a line which says
BCVGF%6$#900 .....How can we know which position is for % or say $ by command or script?There is any way to get a prompt by any script?
Thanks a lot (6 Replies)
Hi, I'm using AIX 5.3 and am trying to get this to work as I need:
echo 6078: 6072 6073 6074 6075 6076 6077 6078 6079 | awk '{n=$8} n{sub(n,n+1000000)}1'
1006078: 6072 6073 6074 6075 6076 6077 6078 6079I only want it to change second occurance of 6078 (ie $8) and not the first ($1).
I... (4 Replies)
Hi guys.
I'd just like to know if its possible to change the actual line/row position in awk while its busy processing a file. In other words, is it possible to jump from line 10, back up to line 5 and continue processing line-by-line from then onwards? or is the way around this to add all lines... (3 Replies)
I'm plowing through a bunch of text (and I have to use awk) and need to identify which position a certain string is in. Consider the two lines...
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1372 Metric:1
UP LOOPBACK RUNNING MTU:16436 Metric:1
I can identify the line by searching for MTU:.... (3 Replies)
I want to remove text from nth position to nth position couple of times in same line
my line is
"hello is there anyone can help me with this question"
I need like this
ello is there anyone can help me with question
'h' is removed and 'this' removed from the line. I want to do this... (5 Replies)