How to extract previous value


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to extract previous value
# 8  
Old 03-08-2011
Code:
awk -v RS="Name += +" -v FS="\n" '$2!~/0x000/&&/./{print $1}' file

---------- Post updated at 03:21 AM ---------- Previous update was at 03:20 AM ----------

Code:
1 can be considered as {print $0}

# 9  
Old 03-08-2011
Maybe small example will make it clear. Those two lines are equivalent:
Code:
awk '1' file

Code:
awk '{print $0}' file

# 10  
Old 03-08-2011
Thanks it helped
# 11  
Old 03-10-2011
Thanks a lot, the first two solutions are prefectly working fine. just wanted to know-

{prnit x} {x=$3} how it works, what it means...?

awk '$1=="State" && $3!~"0x0000"{print x}{x=$3}'

Thanks,
Naresh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract row grater than 3 from previous value of a field

Hi, I am trying to extract data where first field unique value and 4th field of next row is grater than first row 4th field. input data is a below: 7035719974,20-jul-2016 07:42:51,07:42:51,074251,1 7035719974,20-jul-2016 07:43:57,07:43:57,074357,2 7399206761,20-jul-2016... (2 Replies)
Discussion started by: rramkrishnas
2 Replies

2. UNIX for Dummies Questions & Answers

AIX UNIX - script on how to extract from log file with previous date

Hello, I am new to this forum so any assistance would help. I am currently trying to develop a script that extract all data from a log file with has the previous day's date. $ <root@aixtest3> /var/log > more sudo.log May 13 10:52:10 aixtest3 local2:notice sudo: tbrath : TTY=unknown ; ... (14 Replies)
Discussion started by: Kslew82
14 Replies

3. Shell Programming and Scripting

Print previous (non zero)

Dear All, I have file like this, 13819 32.07 1877.65 0 481.81 2100.86 0 789.35 2274.05 0 4627.61 4421.36 0 5831.52 4855.50 20844 38.68 1902.15 0 291.02 1945.88 0 452.57 2013.94 0 2194.28 ... (6 Replies)
Discussion started by: attila
6 Replies

4. Shell Programming and Scripting

Help with getting last date of previous month and first date of previous 4th month from current date

I have requirment to get last date of previous month and the first date of previous 4th month: Example: Current date: 20130320 (yyyymmdd) Last date of previous month: 20130228 (yyyymmdd) First date of previous 4th month: 20121101 (yyyymmdd) In my shell --date, -d, -v switches are not... (3 Replies)
Discussion started by: machomaddy
3 Replies

5. Shell Programming and Scripting

Remove previous line if next & previous lines have same 4th character.

I want to remove commands having no output. In below text file. bash-3.2$ cat abc_do_it.txt grpg10so>show trunk group all status grpg11so>show trunk group all status grpg12so>show trunk group all status GCPKNYAIGT73IMO 1440 1345 0 0 94 0 0 INSERVICE 93% 0%... (4 Replies)
Discussion started by: Raza Ali
4 Replies

6. Shell Programming and Scripting

Search for a pattern,extract value(s) from next line, extract lines having those extracted value(s)

I have hundreds of files to process. In each file I need to look for a pattern then extract value(s) from next line and then search for value(s) selected from point (2) in the same file at a specific position. HEADER ELECTRON TRANSPORT 18-MAR-98 1A7V TITLE CYTOCHROME... (7 Replies)
Discussion started by: AshwaniSharma09
7 Replies

7. Shell Programming and Scripting

To get the previous 5 minutes

Hi I need to get the previous 5 minutes from the currnet time as given below. Please help. Current time : date +%d-%m-%Y_%H-%M output : 16-05-2012_15-05 I need the previous 5 minutes of the above output , Required output: 16-05-2012_15-04 16-05-2012_15-03... (4 Replies)
Discussion started by: Kanchana
4 Replies

8. Shell Programming and Scripting

How to get previous date

Hello, Apologies for not following the forum rules. I will follow it from now on. What I need now is to get the previous date in PERL. Today is 07/01/2010...and the prev date is 06/30/2010. Could you please show me the (localtime) syntax of how to write this so it works in all... (3 Replies)
Discussion started by: nurani
3 Replies

9. Forum Support Area for Unregistered Users & Account Problems

previous posts

Hi, is there a way I can display my previous question posted? I've had a look around but couldn't find anything. Thanks in advance, Simon. (2 Replies)
Discussion started by: james6
2 Replies

10. HP-UX

Previous command

Hi, i would like to retrieve (only retrieve, not execute) a previous command which i executed on the command prompt. I tried the 'up arrow' key, but its not working. Instead,it showed me some funny characters. I searched around and i found the way to do it was using the way below. Several... (5 Replies)
Discussion started by: new2ss
5 Replies
Login or Register to Ask a Question