grep: not found


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting grep: not found
# 1  
Old 10-26-2012
grep: not found

Hi,

running below korn shell script

Code:
#!/bin/ksh
chk_dump()
{
CNT=`ls *.dmp|grep $DATE|wc -l`
if [$CNT -gt 0]; then
echo "delete_dumpfile"
else
echo "start_exp"
fi
}
 
chk_dump


getting below error:

Code:
./test1.sh[3]: wc: not found
./test1.sh[3]: ls: not found
./test1.sh[3]: grep: not found
./test1.sh[4]: test: ] missing


is there something missing ?

Last edited by Scrutinizer; 10-26-2012 at 08:23 AM.. Reason: code tags
# 2  
Old 10-26-2012
What is output of this..?

Code:
echo $PATH

I think you have changed its value.
This User Gave Thanks to pamu For This Post:
# 3  
Old 10-26-2012
Code:
if [ $CNT -gt 0 ]; then

test conditions' square brackets should be spaced properly like above...
Quote:
Originally Posted by milink
Hi,

running below korn shell script

#!/bin/ksh
chk_dump()
{
CNT=`ls *.dmp|grep $DATE|wc -l`
if [ $CNT -gt 0 ]; then
echo "delete_dumpfile"
else
echo "start_exp"
fi
}

chk_dump


getting below error:

./test1.sh[3]: wc: not found
./test1.sh[3]: ls: not found
./test1.sh[3]: grep: not found
./test1.sh[4]: test: ] missing


is there something missing ?
# 4  
Old 10-26-2012
Yes, issue was with $PATH, it worked after correction.

Thanks !!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep everything between two pattern if match not found

I need to help to work this Print everything between 2 patterns if grep is not found the search word example Detroit orange cat bat rat apple sed -n "/Detroit,/apple/p" d |grep chicago output would be Detroit orange cat bat rat (1 Reply)
Discussion started by: jhonnyrip
1 Replies

2. UNIX for Dummies Questions & Answers

Grep for list of files with only found hits

Hi, With grep -ci word * I get a list of files either they have a hit, or the have not (0). I wanted to pipe to a new list of files, which only shows the files where the string was found, and counted, not the whole bunch. How to do this? Any advice welcome! with best regards, Omar... (11 Replies)
Discussion started by: OmarKN
11 Replies

3. Shell Programming and Scripting

Grep and replace with found string

Hi, I need to find all rows in 1st col of one file in another file (first occurrence) and replace the 1st col of first file with the grep result (the entire line). For example search AA from file 1 in file 2 and replace in file 1 by entire line found. File1 AA BB CC DD BB AA CC DDFile2 ... (2 Replies)
Discussion started by: ritakadm
2 Replies

4. Shell Programming and Scripting

kill a process if grep match is found

Hi, I need something unusual, I guess. I need to start a process, and if that process displays a specific error message, I need to kill that process and restart it. Something like: startprocess | grep -i "This is the specific error message" && kill $pidof(startprocess) Explanation, I need... (4 Replies)
Discussion started by: burek
4 Replies

5. Shell Programming and Scripting

Insert blank line if grep not found

Hi all, I've googling around forum regarding my prob, the nearest would same as thread tittled Insert blank line if grep not found, but she/he did not mention the solution, so I would like to request your help I've this task, to search in file2 based on pattern in file1 and output it to... (4 Replies)
Discussion started by: masterpiece
4 Replies

6. Shell Programming and Scripting

How to grep for message and if found display filename?

Hi i'm new to the forum and was hoping someone could help me with the following query. I do alot of testing and have hundreds of log files output. I have a script (someone else wrote) which finds all the passed and failed logs and puts a number in a column onto a webpage: e.g: Pass ... (4 Replies)
Discussion started by: defamer
4 Replies

7. Shell Programming and Scripting

read the first 10 lines below a keyword found by grep

Hello Everyone, i need to read specific number of lines ( always serialized ; i.e from 10 to 20 or from 34 to 44 ) in a file , where the first line is found by grep 'ing a keyword. example file.txt ------------------------------------------------------------------ --header this is the... (7 Replies)
Discussion started by: alain.kazan
7 Replies

8. UNIX for Dummies Questions & Answers

Grep and display n lines after the match is found.

Hello, How do I use grep to find a pattern in a list of file and then display 5 lines after the pattern is matched Eg: I want to match the string GetPresentCode in all files in a folder and then see 4 lines following this match. I am not sure if grep is what should be used to achieve. Thanks!... (3 Replies)
Discussion started by: cv_pan
3 Replies

9. AIX

grep to give how many times each lines were found

Lets say I have a file containing string patterns to be looked for inside a file. I would normaly do : grep -if MyFilePattern FiletoSearchInto if I use the -c it gives how many total lines it found out of my whole pattern file, but what if i want grep to report how many times it found each... (4 Replies)
Discussion started by: Browser_ice
4 Replies

10. Shell Programming and Scripting

Insert blank line if grep not found

Hello everyone... please help if you can -- I'm stumped. Making this work will save me hours of manual labor: I need to search file2 for pattern in file1. If pattern found append file2 line to file3. If pattern not found append a blank line to file3. file1 contents example: 123 456 789... (6 Replies)
Discussion started by: michieka
6 Replies
Login or Register to Ask a Question