Awk | Grep pattern

I like to know how to remove all white space from pipe 1 and take the contents over to pipe 3. Note, test2.txt file always changes on the hour and I'm hunting down the pattern in test1.txt file. I only know the basic of UNIX and my kung fu is not that strong.

awk 'NR==2' test2.txt | pg test1.txt | grep -e "trying to print NR==2 info here."

pipe 1: awk 2nd line from test2.txt file.
pipe 2: opening text1.txt file.
pipe 3: trying to grep -e the contents of pipe 1 and failing miserably.

I've read this post a few times now, and I have more questions than answers.

I really don't understand what you want.

And what do pipes have to do with kung fu?

Let's take what you've given us:

awk 'NR==2' test2.txt | \      # print line 2 of test2.txt
pg test1.txt | \               # pipe line 2 of test2.txt into pg for reasons unknown
grep -e "trying to..."         # grep for what?

Where does removing whitespace fit into this and what does that have to do with pipes?

Like I said, I don't really understand what you're trying to do.

Here the whole thing. The information stored in file PDSNinfo.txt varies in length on the hour and I want to avoid any issues when I perform a grep. Also I have no idea how to move variable �NR==1� over to "print NR==1".

pg tpstatus.txt | sed -n '16,17p' > PDSNinfo1.txt
pg PDSNinfo1.txt | grep -e "| " | cut -c3-18 > /tmp/flxtpinfo/PDSNinfo2.txt
pg tpstatus.txt | grep -e "TP ID :" | cut -c3-18 > /tmp/flxtpinfo/flxtpinfo1.txt
pg tpstatus.txt | grep -e "TP Status :" | cut -c15-19 > /tmp/flxtpinfo/flxtpinfo2.txt
awk 'NR==1' PDSNinfo2.txt | pg tpstatus.txt | grep -e "print NR==1" | cut -c70-79 >/tmp/flxtpinfo/flxtpinfo3.txt
awk 'NR==2' PDSNinfo2.txt | pg tpstatus.txt | grep -e "print NR==2" | cut -c70-79 >/tmp/flxtpinfo/flxtpinfo4.txt
paste flxtpinfo1.txt flxtpinfo2.txt flxtpinfo3.txt flxtpinfo4.txt > flxtpinfo5.txt
cat flxtemplate.txt flxtpinfo5.txt flxtemplate1.txt > flxtpsessions.txt

If I turn my head 90� your code kinda resembles of the Empire State Building!

You may be lacking an understanding of UNIX pipes.

Have a read of this: Pipeline (Unix) - Wikipedia, the free encyclopedia

At this point I would suggest that you post a sample of your input data and your expected output.

Empire State Building, thanks. When I remove the "awk 'NR==1' PDSNinfo2.txt" and "awk 'NR==2' PDSNinfo2.txt" and vi the file on what to "grep -e" it works fine.

awk 'NR==1' PDSNinfo2.txt | pg tpstatus.txt | grep -e "print NR==1" | cut -c70-79 >/tmp/flxtpinfo/flxtpinfo3.txt
awk 'NR==2' PDSNinfo2.txt | pg tpstatus.txt | grep -e "print NR==2" | cut -c70-79 >/tmp/flxtpinfo/flxtpinfo4.txt

---------- Post updated 11-22-09 at 10:17 AM ---------- Previous update was 11-21-09 at 02:44 PM ----------

I got it; and thank you for helping.

pg tpstatus.txt | sed -n '16,17p' > PDSNinfo1.txt
pg PDSNinfo.txt | /usr/xpg4/bin/grep -e "| " | cut -c3-18 > /tmp/flxtpinfo/PDSNinfo2.txt
pg tpstatus.txt | /usr/xpg4/bin/grep -e "TP ID :" | cut -c3-18 > /tmp/flxtpinfo/flxtpinfo1.txt
pg tpstatus.txt | /usr/xpg4/bin/grep -e "TP Status :" | cut -c15-19 > /tmp/flxtpinfo/flxtpinfo2.txt
PDSNip1=$(awk 'NR==1' PDSNinfo2.txt) ; PDSNip2=$(awk 'NR==2' PDSNinfo2.txt)
pg tpstatus.txt | /usr/xpg4/bin/grep -e "$PDSNip1" | cut -c70-79 >/tmp/flxtpinfo/flxtpinfo3.txt
pg tpstatus.txt | /usr/xpg4/bin/grep -e "$PDSNip2" | cut -c70-79 >/tmp/flxtpinfo/flxtpinfo4.txt
paste flxtpinfo1.txt flxtpinfo2.txt flxtpinfo3.txt flxtpinfo4.txt > flxtpinfo5.txt
cat flxtemplate.txt flxtpinfo5.txt flxtemplate1.txt > flxtpsessions.txt