The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" iBot UNIX and Linux RSS News 0 01-04-2008 12:00 PM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-19-2007 10:52 PM
grep to find content in between curly braces, "{" and "}," keshav_rk Shell Programming and Scripting 4 08-09-2007 07:14 PM
grep/cat/more -- search in a txt file and display content from a specific "keyword" I-1 UNIX for Dummies Questions & Answers 4 02-21-2007 01:57 AM
No utpmx entry: you must exec "login" from lowest level "shell" peterpan UNIX for Dummies Questions & Answers 0 01-18-2006 01:15 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-29-2006
Registered User
 

Join Date: Jan 2006
Posts: 126
grep "$1\.mylogs\.20" ?

Can any kind souls explain the above to me please?

In additional, the following line (within brackets) also muffles me, please enlighten me.
( awk '{print $2}' )
Reply With Quote
Forum Sponsor
  #2  
Old 01-29-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,698
grep "$1\.mylogs\.20"

Usually $1 is the first parameter passed to a shell script.

Say, $1 is new2ss in this case.

So the search string is

"new2ss.mylogs.20"

The \ is used to escape the character which appears just after the \

In the unix world, a . represents any character. So a /. would mean a . in its entirety.

Your grep search pattern can be like this as well
grep "$1.mylogs.20"
Reply With Quote
  #3  
Old 01-30-2006
Registered User
 

Join Date: Jan 2006
Posts: 126
Thanks , Vino.
Any idea what does ' awk {print $2} ' do ?
Reply With Quote
  #4  
Old 01-30-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,698
Code:
[~]$ echo "Welcome to the unix forums" | awk '{ print $2 }'
to
It would break the statement "Welcome to the unix forums" into tokens delimited by white-space and print the second token.

For more info read the man pages of awk.

Last edited by vino; 01-30-2006 at 08:15 AM.
Reply With Quote
  #5  
Old 02-02-2006
Registered User
 

Join Date: Jan 2006
Posts: 126
Thank you, vino
Reply With Quote
  #6  
Old 07-04-2007
Registered User
 

Join Date: Jun 2007
Location: Mumbai,India
Posts: 99
new2ss, please get some basic understanding about regular expression syntex. so that u wont get any problem in future.
these are not so difficult.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:07 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0