Get previous value in column


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get previous value in column
# 8  
Old 08-16-2016
The question was WHERE you would start to modify your insufficient attempt.

Howsoever, try
Code:
awk '{if($1 < prev -50) {printf ("%4d then %4d then %4d \n",prv2, prev, $1) } ; prv2 = prev; prev = $1}' file1
 644 then  726 then  645

This User Gave Thanks to RudiC For This Post:
# 9  
Old 08-16-2016
Thanks a lot to all
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Fill column from previous row

Hi, I have the following content in file ABBR DESC COL3 COL4 COL5 COL6 AAA text desc aaa text text text text text text text text text text text text BBB text desc bbb text text text text text text text text CCC ... (10 Replies)
Discussion started by: bobbygsk
10 Replies

2. Shell Programming and Scripting

Fill data in column with previous value

Gents, Kindly help me. I have a file with empty values in selected column, I will like to fill the empty values with the previous value. Example Input file X 4959 30010 66727.00 20457.001 1 1441 66512.00 20234.00 20520.001 X 4959 30010 66727.00 20457.001 145 ... (7 Replies)
Discussion started by: jiam912
7 Replies

3. Shell Programming and Scripting

Insert data in first column(if blank) from previous line first column

Dear Team I need to insert field(which is need to taken from previous line's first field) in first column if its blank. I had tried using sed but not find the way. Detail input and output file as below. Kindly help for same. INPUT: SCGR SC DEV DEV1 NUMDEV DCP ... (7 Replies)
Discussion started by: jaydeep_sadaria
7 Replies

4. 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

5. Shell Programming and Scripting

Read column values from previous and next line using awk

Hi, I have a csv file which contains data that looks something like this: Key1 Key2 Key3 New_Key1 New_Key2 New_Key3 102 30 0 - - - 102 40 1 30 40 50 102 50 2 40 50 ... (4 Replies)
Discussion started by: Nishi_Licious
4 Replies

6. Shell Programming and Scripting

Previous Column Value (addition)

Good day, First off, I would just like to say that I've been helped by a lot of the posts here in my own scripting work in the past few months. I've been a long time roamer, but first time poster. That being said, I'm stuck trying to figure out this issue (For computational research, not a... (4 Replies)
Discussion started by: Eblue562
4 Replies

7. Shell Programming and Scripting

Compare two files using awk or sed, add values in a column if their previous fields are same

Hi All, I have two files file1: abc,def,ghi,5,jkl,mno pqr,stu,ghi,10,vwx,xyz cba,ust,ihg,4,cdu,oqw file2: ravi,def,kishore ramu,ust,krishna joseph,stu,mike I need two output files as follows In my above example, each row in file1 has 6 fields and each row in file2 has 3... (3 Replies)
Discussion started by: yerruhari
3 Replies

8. Shell Programming and Scripting

eAdd two fields in a column if their previous field values are same

Hi All, I have two files file1: abc,def,ghi,5,jkl,mno pqr,stu,ghi,10,vwx,xyz cba,ust,ihg,4,cdu,oqw file2: ravi,def,kishore ramu,ust,krishna joseph,stu,mike I need two output file as follows If field3 in file1 is same as field3 in the next line then the field4 should add... (1 Reply)
Discussion started by: yerruhari
1 Replies

9. UNIX for Dummies Questions & Answers

Compare two files using awk or sed, add values in a column if their previous fields are same

Hi All, I have two files file1: abc,def,ghi,5,jkl,mno pqr,stu,ghi,10,vwx,xyz cba,ust,ihg,4,cdu,oqw file2: ravi,def,kishore ramu,ust,krishna joseph,stu,mike I need two output files as follows In my above example, each row in file1 has 6 fields and each row in file2 has 3... (1 Reply)
Discussion started by: yerruhari
1 Replies

10. UNIX for Advanced & Expert Users

Compare two files using awk or sed, add values in a column if their previous fields are same

Hi All, I have two files file1: abc,def,ghi,5,jkl,mno pqr,stu,ghi,10,vwx,xyz cba,ust,ihg,4,cdu,oqw file2: ravi,def,kishore ramu,ust,krishna joseph,stu,mike I need two output files as follows In my above example, each row in file1 has 6 fields and each row in file2 has 3... (1 Reply)
Discussion started by: yerruhari
1 Replies
Login or Register to Ask a Question