plz correct this


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting plz correct this
# 1  
Old 04-26-2007
plz correct this

grep pattern a.log|grep -e "p1" |cut -d":" -f1,2,3,4,8,9,10|cut -d"/" -f5 -e "p2" |cut -d":" -f1,2,3,4,6|cut -d"/" -f5 >> file

Dont know why the above command isnt working :-(

can someone correct me...
# 2  
Old 04-26-2007
the best is to give a sample of that a.log file, and your desired output format.
# 3  
Old 04-26-2007
Quote:
Originally Posted by wannalearn
grep pattern a.log|grep -e "p1" |cut -d":" -f1,2,3,4,8,9,10|cut -d"/" -f5 -e "p2" |cut -d":" -f1,2,3,4,6|cut -d"/" -f5 >> file

Dont know why the above command isnt working :-(

can someone correct me...
Remove -e "p2"
Code:
cut -d"/" -f5 -e "p2" 

# 4  
Old 04-26-2007
well

well i need that -e there as i wanna search for another pattern....do u think i need to use braces anywhere?
# 5  
Old 04-26-2007
Quote:
Originally Posted by wannalearn
well i need that -e there as i wanna search for another pattern....do u think i need to use braces anywhere?
Change
Code:
cut -d"/" -f5 -e "p2"

to
Code:
cut -d"/" -f5 | egrep  -e "p2"

You cannot search for a pattern in cut command
# 6  
Old 04-26-2007
If i do this
cut -d"/" -f5 | egrep -e "p2"
it will be grepping on the output because we are using the pipe....

grep pattern a.log|grep -e "p1" |cut -d":" -f1,2,3,4,8,9,10|cut -d"/" -f5 -e "p2" |cut -d":" -f1,2,3,4,6|cut -d"/" -f5 >> file

So i used the grep -e


I want to search for pattern one do the cutting part then search for pattern two and do the cutting part for that in the same log instead of grepping two times

grep pattern a.log|grep "p1" |cut -d":" -f1,2,3,4,8,9,10|cut -d"/" -f5
grep pattern a.log|grep "p2" |cut -d":" -f1,2,3,4,6|cut -d"/" -f5

i have to execute the above command by using grep only once :-)
# 7  
Old 04-26-2007
hmmm..

Sorry by using grep thrice totally not four times :-)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

help me plz

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: *I want to Write shell script to print the this pattern: 1 22 333 4444 55555 *I want to Write shell... (2 Replies)
Discussion started by: last exile
2 Replies

2. Shell Programming and Scripting

help me plz

can you help me to answer these questions ... Q1 - Write shell script to print the following pattern: 1 22 333 4444 55555 Q2- Write shell script to compare the strings, check and see if a command line argument matched the string "net321" print on screen "** string matches ** " if... (3 Replies)
Discussion started by: last exile
3 Replies

3. Shell Programming and Scripting

plz help me

hi... i want to print the below format by using shell scripting...plz help me 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 Thanking u in advance... regards ram (1 Reply)
Discussion started by: ram_pl
1 Replies

4. UNIX for Dummies Questions & Answers

PLZ help..!!

plz help me with this question : 1111 | aaaa | pppp | 23/9/87 3333 | dddd | oooo | 6/9/8 4444 | gggg | rrrr | 5/8/9 5555 | qqqq | eeee ans: 5555 | qqqq | eeee depending upon how many "|" are in the question be quick.. (8 Replies)
Discussion started by: adityamitra
8 Replies

5. Shell Programming and Scripting

Plz correct my syntax of shell script

Dear all I am still bit new in shell script area.I am writing down a shell script which I guess somewhere wrong so please kindly correct it. I would be greatful for that. What I actually want from this shell script is that it will move all the files one by one to another server which can be... (2 Replies)
Discussion started by: girish.batra
2 Replies

6. UNIX for Dummies Questions & Answers

plz help me...

unfortunately...i created directory with name "-rf" but now am unable to remove it. (6 Replies)
Discussion started by: venkatramana
6 Replies

7. Shell Programming and Scripting

Correct the error plz

Hi, I'll get a file whose first line comprises of system name, timestamp of file creation and the seq number. System name and seq num I need to other computation. My requirement is, I'll have to check whether the timestamp is greater than current timestamp and also check if the timestamp is... (2 Replies)
Discussion started by: Mandab
2 Replies

8. Shell Programming and Scripting

Plz help

I am a newbie to Unix, I am using vi editor. I was able to print output to the screen using simple scripts. But when I tried a midlevel script I don't see anything on the screen and Cursor is just blinking when I type ./test11 filename. I have used chmod 755 also, but of no use. Any help would... (3 Replies)
Discussion started by: Mandab
3 Replies

9. Programming

plz help!

i'm pretty new to unix programming. i just wanna know how exactly fork(), waitpid() works. i have read some from the book, but it's still confusing. especially with those < 0 and == 0. plz help!!!! (1 Reply)
Discussion started by: ligerdave
1 Replies

10. UNIX for Dummies Questions & Answers

plz Help How should I configure cc compiler output file plz help???

i.e configuration of C compiler :confused: (4 Replies)
Discussion started by: atiato
4 Replies
Login or Register to Ask a Question