10-30-2003
Grep from a file variable
I am wanting to test the output from a script. If the out put = Object does not exist. I need to delete the output file.
I am using , filecontents=`grep -i Object does not exist. $1.txt`
then I test the variable with,
if [ ${filecontents} = "Object does not exist." ]; then
delete file
But I get an error, grep: can't open leave_crew_allow_v.txt. Where leave_crew_allow_v.txt is the actual name assigned to the variable.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I'd like to grep a variable that I saved in the program.
Like
grep '0\$variable1' file1
Does someone know what's wrong with this command?
Thanks a lot! (2 Replies)
Discussion started by: whatisthis
2 Replies
2. Shell Programming and Scripting
Hello! I think this should be an easy solution. I have a large file with many fields of data. The first field has a unique identifier (a subject number) for every record for a chunk of data. Something like this:
There were ten experimental conditions (ec), but the ec is identified by only... (11 Replies)
Discussion started by: ccox85
11 Replies
3. Shell Programming and Scripting
All I want to do is find out if the string 'NO' is in a file by checking for a return code of 0 if there is a match. The grep works fine on the command line directly naming the file but I am obviously not using the correct syntax within the shell script as I consistently get the error message
... (5 Replies)
Discussion started by: SusanDAC
5 Replies
4. Shell Programming and Scripting
Hey guys,
I'm attempting to compare the contents of two files that are not identical on a Solaris 10 box. We are under audit and I need to do some comparisons of our application accounts with our unix accounts. I essentially want to pull a line from one file and search the second for an equal... (1 Reply)
Discussion started by: kaledragule
1 Replies
5. Shell Programming and Scripting
how can I use grep with a variable to find a value?
cat data.out
Hello World
grep "Hello World" data.out
Hello World ## Value found
I want to do something like this but can't seem to get it to work any
suggestions would be appreciated.
var="Hello World"
grep $var data.out (3 Replies)
Discussion started by: BeefStu
3 Replies
6. Shell Programming and Scripting
I want to search a text in file but that file is pointing to variable.
ex:
file=there was nothing special
grep "there was nothing" $file
but its not working . Can u let me know that how we can use variable($file) in grep command.
Please use code tags (6 Replies)
Discussion started by: allthanksquery
6 Replies
7. Shell Programming and Scripting
I have a pattern like:
column "5" is missing
PS: the no is in double quotes.
The number usally changes, so we use a loop to grep.
grep 'column "$number" is missing' filename.txt
But it is not working....
How to solve this? (2 Replies)
Discussion started by: karumudi7
2 Replies
8. Shell Programming and Scripting
Hi,
I have a loop running until a variable L that is read previously in the full script. I'd like to grep some information in an input file at a line that contains the value of the loop parameter $i.
I've tried to use grep, but the problem is nothing is written in the FILE files. It seems grep... (5 Replies)
Discussion started by: DMini
5 Replies
9. Shell Programming and Scripting
Hi,
I am looking for the following:
1. A command to 'grep' the variable from a file
2. And check whether the entered variable is empty in that file
I have a file as given below:
IAGLOBAL_USERID=admin
I want to check with a whether the variable contains a value, say here its admin if... (2 Replies)
Discussion started by: dbashyam
2 Replies
10. Shell Programming and Scripting
I've got a file that I'm trying to grep through that looks like this:
alpha1
alpha2
alpha3
beta1
beta2
gamma5
gamma6
gamma7
gamma8
gamma9
and I want the output to only contain the line with the highest value for each, so the output I want is:
alpha3
beta2
gamma9
I also need... (11 Replies)
Discussion started by: tiberione
11 Replies