Shell Scripting Question
I'm trying to automate the removal of a user from a mailing list. If I try these commands from the command line everything works great, but when I run my script, it doesn't work a bit.
echo "Enter username:" read username egrep -v '($user)' mailing.list > temp mv temp mailing.list All the paths and permissions are correct, I'm running the script as root within my own directory so neither of those are an issue. Any ideas? Thanks, Chris |
Error messages when running? And what do you mean by "work a bit" ? Like it half works or something.. ? :confused:
|
"it doesn't work a bit." <- which means it doesnt work at all
No error messages either |
Have you noticed you read "username" and use "user" in your egrep command?
|
You're reading user input into a UDV called "username" and then trying to use "$user" in your egrep command. Methinks that may be an issue?
|
I said it first, I must get the credits :D
|
My bad, I was just trying to give an example of the command, but in the script below, it looks the same as the script I'm having trouble with.
echo "Enter username:" read user egrep -v '($user)' mailing.list > temp mv temp mailing.list |
hm... does your list remain untouched as if you hadn't run the script on it?
|
it doesnt matter because it was a typo.
|
Tthe timestamp on the file is updated, but the user is not being removed from the list. So that means that the script does actually do something, but not what I want.
|
Show me a sample line (with all vital data removed, of course) from your mailing.list file. It's definitely something with the matching, because the file is being dumped to "temp" and then moved over to mail.list again. egrep is just not matching that particular line.
|
I got it, what I did was I removied the '( )' from the egrep command so it looks like:
egrep -v $user mailing.list > temp mv temp mailing.list Thanks for everyones help... |
That's where I was about to go :)
Best of luck! |
All times are GMT -5. The time now is 03:54 AM. |