- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Problems to use grep when there is a variale with ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2006 08:06 AM
тАО06-02-2006 08:06 AM
${logftp}_out=fileout
i have a file nane which is named "fileout" contains:
200 PORT command successful.
150 Opening ASCII mode data connection for CNA-HOLDINGS-NJ-AR-I.
-C--------FTP B BLABLABLA 215946 15661 Jun 02 14:57 FILE_A
Total number of batches listed: 1
I have this variable in my script:
unixx:user1> dia2=`date +'%b %d'`
unixx:user1> echo $dia2
Jun 02 (there is a space between Jun and 02)
i wat to obtain the line where is the date, i do this one taking the date :
${logftp}_out = fileout
unixx:user1> cat ${logftp}_out | grep $dia2
grep: can't open 02
how can i do to grep takes of part as parameter of dia2 the number 02?
Thanks ...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2006 08:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2006 08:16 AM
тАО06-02-2006 08:16 AM
Re: Problems to use grep when there is a variale with several spaces between spaces ....
Change your grep command so that the string you need to search for is presented as a single argument by surrounding it with double-quotes like...
unixx:user1> cat ${logftp}_out | grep "$dia2"
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2006 08:21 AM
тАО06-02-2006 08:21 AM
Re: Problems to use grep when there is a variale with several spaces between spaces ....
and if i have:
dia1=`date "+%b %d"|$ppppp -pe 's/(...)0(\d)/$1 $2/'`
echo "${dia}"
Jun 2 #there is two spaces between Jun and 2"
how can i use grep here?
Thanks ....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2006 08:29 AM
тАО06-02-2006 08:29 AM
Re: Problems to use grep when there is a variale with several spaces between spaces ....
# grep "$dia1"
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-04-2006 02:08 PM
тАО06-04-2006 02:08 PM
Re: Problems to use grep when there is a variale with several spaces between spaces ....
Using "$somevariable" will tell the shell to treat this as one long string including all spaces. grep will see this long string and will perform the search using the entire string.
The single quote '$somevariable' turns off all special handling for every character so grep will be looking for $somevariable and not the contents of that variable.
Bill Hassell, sysadmin