Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Using current line in a command in AWK Post 302488298 by m4rty on Sunday 16th of January 2011 02:21:49 PM
Old 01-16-2011
Data Using current line in a command in AWK

Hi, Im trying to get current line in the AGREP command I use in AWK. My script looks like this:

Code:
list.txt
car
bus

checklist.txt
cer
buss

cat list.txt | awk -v mycmd="$(agrep -2 -i $0 checklist.txt)" '{print $mycmd}'

It doesnt work. How can I get the current line in the $0 variable? Or is there any different solution? I need to go through each line in list.txt, search & compare it in checklist.txt and get a result.

Thank u for ur responses.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using awk and current date command

I am running a command to extract data from a database which has different text and dates (ex. 01/03/07, 05/29/08, 06/05/08). Once the file is created I need to grep for all the text with a current date then redirect the sorted data to another file then email the file out. Here is what I have right... (2 Replies)
Discussion started by: wereyou
2 Replies

2. Shell Programming and Scripting

assign a command line argument and a unix command to awk variables

Hi , I have a piece of code ...wherein I need to assign the following ... 1) A command line argument to a variable e.g origCount=ARGV 2) A unix command to a variable e.g result=`wc -l testFile.txt` in my awk shell script When I do this : print "origCount" origCount --> I get the... (0 Replies)
Discussion started by: sweta_doshi
0 Replies

3. Shell Programming and Scripting

awk print the next line on the current line

Ok I have a file with hundreds of lines, four columns, space delimited, TESTB.TXT for example TESTB.TXT --- AA ZZ 12 34 BB YY 56 78 CC XX 91 23 DD VV 45 67 --- I want a new file that has 7 columns, the first four are identical, and the next 3 are the last three of the next line...so... (5 Replies)
Discussion started by: ajp7701
5 Replies

4. Shell Programming and Scripting

Vi Editor - How to paste the line concatenated with current line

I generally use yy to copy a line and then p to paste the line at end of current line. But is there a way to paste the copied line in concatenation with the current line with out going to next line. (3 Replies)
Discussion started by: paragkalra
3 Replies

5. UNIX for Dummies Questions & Answers

Awk to print data from current and previous line

Hi guys, I have found your forum super useful. However, right now I am stuck on a seemingly "simple" thing in AWK. I have two columns of data, the first column in Age (in million years) and the second column is Convergence Rate (in mm/yr). I am trying to process my data so I can use it to... (2 Replies)
Discussion started by: awk_noob_456
2 Replies

6. Shell Programming and Scripting

Sed Comparing Parenthesized Values In Previous Line To Current Line

I am trying to delete lines in archived Apache httpd logs Each line has the pattern: <ip-address> - - <date-time> <document-request-URL> <http-response> <size-of-req'd-doc> <referring-document-URL> This pattern is shown in the example of 6 lines from the log in the code box below. These 6... (1 Reply)
Discussion started by: Proteomist
1 Replies

7. Shell Programming and Scripting

Pass awk field to a command line executed within awk

Hi, I am trying to pass awk field to a command line executed within awk (need to convert a timestamp into formatted date). All my attempts failed this far. Here's an example. It works fine with timestamp hard-codded into the command echo "1381653229 something" |awk 'BEGIN{cmd="date -d... (4 Replies)
Discussion started by: tuxer
4 Replies

8. Shell Programming and Scripting

Append Next line with current Line bassed on condition

Hi, I have an XML file and I am tring to extract some data form it, after lot of data cleaning process, I ended up with an issue, and need your urgent support. my current input data in below format: <Node>xxxxxx <Node>yyyyy</Node> <Node>zzzzzz <Node>12345</node> I need... (9 Replies)
Discussion started by: rramkrishnas
9 Replies

9. Shell Programming and Scripting

Copy Column Value Of Next Line Into Current Line

Hello All, I am looking for help to achieve the following: Here is the data set 1757890237|42|55570025|1468796400|0 1757890237|32|55570025|1471474800|0 1757890237|54|55570025|1474153200|1476745200 1757890237|34|55570026|1468796400|0 1757890237|44|55570026|1471474800|0... (7 Replies)
Discussion started by: angshuman
7 Replies

10. HP-UX

awk command in hp UNIX subtract 30 days automatically from current date without date illegal option

current date command runs well awk -v t="$(date +%Y-%m-%d)" -F "'" '$1 < t' myname.dat subtract 30 days fails awk -v t="$(date --date="-30days" +%Y-%m-%d)" -F "'" '$1 < t' myname.dat awk command in hp unix subtract 30 days automatically from current date without date illegal option error... (20 Replies)
Discussion started by: kmarcus
20 Replies
EVENT2VRULE(1)						      General Commands Manual						    EVENT2VRULE(1)

NAME
event2vrule - adds 'events' to rrdtool graphs SYNOPSIS
event2vrule <params> DESCRIPTION
Adding Events to Graphs There is a new graphing feature which allows you to specify events that should be displayed in your graphs. These events are simply a list of points in time at which something of interest occurred. For instance, one could create a plain text file in the graphs directory called events.txt containing these lines: 2001/02/10 1538 added support for events to FlowScan graphs 2001/02/12 1601 allowed the events file to be named on make command line Then to generate the graphs with those events included one might run: $ make -f graphs.mf events=events.txt This feature was implemented using a new script called event2vrule that is supplied with FlowScan. This script is meant to be used as a ``wrapper'' for running rrdtool(1), similarly to how one might run nohup(1). E.g.: $ event2vrule -h 48 events.txt rrdtool graph -s -48h ... That command will cause these VRULE arguments to be passed to rrdtool, at the end of the argument list: COMMENT: VRULE:981841080#ff0000:2001/02/10 1538 added support for events to FlowScan graphs COMMENT: VRULE:982015260#ff0000:2001/02/12 1601 allowed the events file to be named on make command line COMMENT: SEE ALSO
add_ds.pl(1), add_txrx(1), flowscan(1), ip2hostname(1), locker(1) AUTHOR
This manual page was written by Anibal Monsalve Salazar, for the Debian Project. EVENT2VRULE(1)
All times are GMT -4. The time now is 01:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy