I am trying to make a script that has grep finding lines that I get from the cat command, that start with something and end with an argument. I can get the first part, but whenever I try to add on the part that looks at the end of the line too, it stops working. Any ideas why? Here is my script:
Thank you for any insight.
Edit: Using xtrace it says that variable name must start with a letter. I am guessing that the format in the $argv[1] is wrong, but I'm not sure. I've tried using quotes around it and single backquotes around it also.
Last edited by sammythesp3rmy; 11-03-2013 at 03:55 PM..
I am getting no error messages now, but I am not getting the results that should come with the script.
For example, my script name is softLinkFinder.txt
I type in softLinkFinder.txt softlink.txt for the command.
With my script, I am trying to get what soft links are to the softlink.txt file. I am trying to do this by creating the script that is using grep to find from ls -l what lines start with an l and end with softlink.txt
When I type in ls -l I get:
my script is a variation of:
I haven't gotten my else set up yet, but when I run the script, grep finds nothing. I am wanting to find the lines that start with l and end with the name of the argument. I think that was all. Thanks
Good Morning,
i ran into some trouble this morning while 'improving' my monitoring stuff. i would like to get a warning when the number of mails sent (outbound) by postfix is above a certain number. so far, so easy. to test that i simply put
cat /var/log/mail.info | grep 'to=<' | grep -v -e... (1 Reply)
PH=(6H 0 0 JD 9S 0 KD 0) #input from .txt file
In the above array, I am trying to get the computer to tell me at what indices the non-zeros are at.
I don't understand why this doesn't work...
grep -v -b "0" ph.txt > position.txt
Isn't grep -v supposed to show non matches in Bash?... (2 Replies)
i have this line of code that looks for the same file if it is currently running and returns the count.
`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`
basically it is assigned to a variable
ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Hi,
I'm using Mac 10.9.1. I would like to create an alias for grep so that it won't print out messages like "grep: /Users/davea/workspace/myproject/subdir/: Is a directory" all the time. So in my terminal, I opened ~/.profile and entered
alias grep='grep -s'
However, when I close and... (5 Replies)
I have a text file (allWords.txt), that I would like to search through. Here is a snippet of what it looks like...
a
aah
aahed
aahing
aahs
aardvark
aardvarks
aardwolf
ab
abaci
aback
abacus
abacuses
abaft
......
I would like to use the grep search to search, line by line, for... (8 Replies)
Hi everyone, thank you so much for reading.
I built a user reference page from /etc/password for a class project. Now I need two shell scripts: 1) Add names to the reference page 2) Delete names from the reference page. I know grep -v is involved somehow and some piping but I am super stuck.
... (1 Reply)
Hi,
I search for the string below which contains a single quote,
some text '/home/myuser
in the file myfile.txt as another user with the grep command as follows
su - myuser -c "grep 'some text \'/home/myuser' myfile.txt"
I also tried using two backslashes
su - myuser... (6 Replies)
Hi there, I'm new to unix-environments.
I'm richard, and i'm mostly a web-developer, under php. I've done work in unix env before, but never had my own.
Today, I've got debian 3.1 r4 from the official site, and i've attempted to install it twice.
I installed it initially as "Desktop... (0 Replies)
I'm not sure where to post this but it's happening on a SunOS 5.8 server so I'll try here.
I've discovered some unexpected behavior when using tr.
For example:
echo a | tr
Z
echo b | tr
a
echo a | tr
B
echo a | tr
B
echo a | tr
A (8 Replies)
Frenz,
I have a file with certain columns from ls -lR which looks something like:
file stemp
----------
lrwxrwxrwx ./temp/s1 -> 2.ksh
lrwxrwxrwx ./temp/s2 -> 3.ksh
lrwxrwxrwx ./temp/subtemp/s3 -> 1.ksh
lrwxrwxrwx ./temp/subtemp/s4 -> 2.ksh
lrwxrwxrwx ./temp/s5 -> ... (9 Replies)