Negating shell interpretation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Negating shell interpretation
# 1  
Old 01-22-2012
Negating shell interpretation

I'm writing a Korn script but am having trouble because the shell interprets the asterisk in this case. Can anyone tell me if there is a way to fix this so that grep takes in STDIN without the interpretation?

Code:
line="30 09 * * 1-4 /home/user01/bin/start"
echo "$line" | grep 'start'

# 2  
Old 01-22-2012
I am not sure what you mean. With the example that you provided, the shell will not interpret the asterisks.
# 3  
Old 01-22-2012
You are correct .. I thought I typed those in manually in to the shell and tested it ... How about this? It's more of what the script looks like:
Code:
#!/bin/ksh

line="01 01 * * 5 /home/user01/bin/start"

if [ $( echo "$line" | grep 'start' ) ]
then
  start="$final"
fi

print $start

It fails at the if statement.
# 4  
Old 01-22-2012
Try this...
Code:
#!/bin/ksh

line="01 01 * * 5 /home/user01/bin/start"

if  grep -q 'start' <<<$line
then
  start="$final"
fi

echo $start

Hope somewhere you have final populated!

--ahamed
# 5  
Old 01-22-2012
Sorry, $final is populated somewhere in the script ... In the following script, I modified it so that it just uses $line instead.

Code:
$ cat g.ksh
#!/bin/ksh

line="01 01 * * 5 /home/user01/bin/start"

if  grep -q 'start' <<<$line
then
  start="$line"
fi

echo $start

$ ./g.ksh
./g.ksh[5]: syntax error at line 5 : `<' unexpected

# 6  
Old 01-22-2012
change the <<< to << 2 "<" characters not 3
# 7  
Old 01-22-2012
Code:
if  echo "$line" | grep -q 'start'
then
  start="final"
fi

--ahamed
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sql multi line comment /* shell interpretation issue

Greetings Experts, I do have some basic knowledge of Unix. The task I am trying to do through shell script is to generate the view script for all of the tables which is in YYYYMMDD format (I assume I am on Ksh). I have certain tables that ends in YYYYMMDD format (eg: tbl_20150630) For each... (1 Reply)
Discussion started by: chill3chee
1 Replies

2. AIX

lspath output interpretation

On my VIo I see the following for my disks: $ lspath | grep hdisk6 Enabled hdisk6 fscsi0 200600a0b82193f7,4000000000000 Enabled hdisk6 fscsi0 200700a0b82193f7,4000000000000 Enabled hdisk6 fscsi2 200600a0b82193f8,4000000000000 Failed hdisk6 fscsi2 200700a0b82193f8,4000000000000 $ lspath |... (8 Replies)
Discussion started by: petervg
8 Replies

3. UNIX for Dummies Questions & Answers

No Space Message Interpretation

Hi, I get the message NOTICE HTFS :No Space on dev hd (1/104), What does (1/104) mean? Is there any link, I can get material on understanding unix message log? thanks. (4 Replies)
Discussion started by: scomrade
4 Replies

4. Shell Programming and Scripting

perl negating Regular Expression

hi all, I have this particular piece of code perl -pi -e 's#\&amp\;(\w\W*\w+\;)#\&$1#gm' filename.txt the (\w\W*\w+\;) part should not contain an "&". That means that if a string like &amp;xxxxx&ecute; comes i wount be replacing the amp;. thanks Jathin (17 Replies)
Discussion started by: jathin12
17 Replies

5. AIX

interpretation of sar

hello with a sar i have this result: System configuration: lcpu=48 ent=4.00 14:06:37 %usr %sys %wio %idle physc %entc 14:06:39 26 9 3 62 1.63 40.7 14:06:41 26 9 3 63 1.58 39.4 14:06:43 ... (0 Replies)
Discussion started by: pascalbout
0 Replies

6. UNIX for Advanced & Expert Users

SAR -b interpretation

I have used SAR -b to get some Unix cache / buffer metrics and the results are confusing me a bit. The pread/s & pwrit/s are showing 0. However the lread/s and lwrit/s are showing figures. I note also that the bread/s and bwrit/s are showing figures. I believe that pread/s and pwrit/s is not... (3 Replies)
Discussion started by: jimthompson
3 Replies

7. UNIX for Dummies Questions & Answers

Interpretation of the uptime command

Hi there, do someone have detailed information how to interpret the uptime command or rather which values can be called normal? (i know what the information means, but i have no idea if these values are ok or to high: 3:02pm an 13:53, 2 Benutzer, Durchschnittslast: 10,06, 12,05, 13,00) ... (5 Replies)
Discussion started by: odin1999
5 Replies

8. UNIX for Dummies Questions & Answers

Prevent bash from interpretation :

I am using bash shell; my requirement is to run a long command. Now I have split this long command into a number of shell variables. Some of these shell variables contain special character ':' At the end, when the intended long command is executed as a series of small shell variables the ':'... (7 Replies)
Discussion started by: uday
7 Replies

9. UNIX for Dummies Questions & Answers

shell interpretation

I executed the following command in the korn shell: $ variable1="qwerty" ls | sort and the shell executed the 'ls | sort' command. I would have expected an error message from the shell, but instead of that the shell ran the 'ls | sort' command and didn't realize the variable assignement. ... (1 Reply)
Discussion started by: PhilippeCrokaer
1 Replies
Login or Register to Ask a Question