
Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tlug] question about shell scripting
- Date: Thu, 25 Jan 2007 17:13:19 +0900 (JST)
- From: scott@example.com
- Subject: [tlug] question about shell scripting
- User-agent: SquirrelMail/1.4.8-2.el4.centos4
Hi everyone,
I am still a newbie to bash shell scripting and have a very quick
question. I would like to perform a command recursively- for example I
would like to list all of the crotabs for all of the users in the system.
So first I get a list of users:
awk -F: '{ print $1 }' /etc/shadow
which is OK. However if I want to use backticks and do something like this:
crontab -l -u `awk -F: '{ print $1 }' /etc/shadow`
it crashes. I'm guessing that the output of that awk is a stream instead
of a list of individual names with a line break. I thought maybe I could
write a for statement in a script this way:
#!/bin/bash
for x in `awk -F: '{ print $1 }' /etc/shadow`;
/usr/bin/crontab -l -u $x;
done
but that crashes as well. I'm pretty sure I could do this in PERL using
an array and then a foreach $line (@), but I'd like to do this in bash,
just to learn more about bash scripting.
Any hints how can I get each iteration of this "for" command to separately
input the usernames into the crontab command, wait for stdout, then
iterate again using a bash script?
Study study,
Scott VanDusen
Tokyo
Home |
Main Index |
Thread Index