![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| add seconds to: date"|"time"|"HHMMSS | anaconga | UNIX for Advanced & Expert Users | 3 | 08-27-2008 01:17 PM |
| Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" | iBot | UNIX and Linux RSS News | 0 | 01-04-2008 03:00 PM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-20-2007 01:52 AM |
| grep to find content in between curly braces, "{" and "}," | keshav_rk | Shell Programming and Scripting | 4 | 08-09-2007 10:14 PM |
| No utpmx entry: you must exec "login" from lowest level "shell" | peterpan | UNIX for Dummies Questions & Answers | 0 | 01-18-2006 04:15 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
xx=`date +"%a %b %d"`;rsh xxx grep "^$XX" zzz ?
AIX 4.2
I am trying to do an rsh grep to search for date records inside server logs by doing this : xx=`date +"%a %b %d"` rsh xxx grep "^$XX" zzz gives : grep: 0652-033 Cannot open Jun. grep: 0652-033 Cannot open 11. But if I do : xx=`date +"%a %b %d"` grep "^$XX" zzz it works ! It is as if when used with something like the 'rsh', the double quotes are removed. Any way around this ? |
|
||||
|
The reason for your problem is the command evaluation process in ksh. You might want to read what i have written for a different (but related) problem here.
Your commandline is first interpreted locally and the content of the variable is filled in and protected by the double quotes. Now a remote connection is opened and the rest of the line is passed as command line to the remote shell interpreter. Guess what? At the remote site the commandline is getting interpreted *again* and now the double quotes are not there any more because they are already "used". The command will look like this (first line=local, second line=remote): Code:
rsh host grep ^Sat Jun 13 06:19:07 CEST 2009 file
--------one argument-----
grep ^Sat Jun 13 06:19:07 CEST 2009 file
The solution is to protect your double quotes by escaping them: Code:
rsh host grep "\"$xx\"" file bakunin |
|
||||
|
Quote:
Thank you. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|