Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] question about shell scripting
- Date: Thu, 25 Jan 2007 17:45:39 +0900
- From: "Josh Glover" <jmglov@example.com>
- Subject: Re: [tlug] question about shell scripting
- References: <43640.210.168.237.209.1169712799.squirrel@example.com>
On 25/01/07, scott@example.com <scott@example.com> wrote:
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
I would advise hitting /etc/passwd instead of /etc/shadow, just because it feels more right.
which is OK. However if I want to use backticks and do something like this:
crontab -l -u `awk -F: '{ print $1 }' /etc/shadow`
This is equivalent to:
crontab -l -u user1 user2 ... userN
Try feeding two usernames to crontab on the command line and see what happens.
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
Close, but no cigar. You left out on minor word that would have made everything work: "do". Dig this:
for x in `awk -F: '{ print $1 }' /etc/shadow`; do /usr/bin/crontab -l -u $x; done
I added indentation to be nice.
HTH, Josh
- Follow-Ups:
- Re: [tlug] question about shell scripting
- From: scott
- References:
- [tlug] question about shell scripting
- From: scott
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] upgraded to 2.6.19.1, stuff won't install
- Next by Date: Re: [tlug] question about shell scripting
- Previous by thread: [tlug] question about shell scripting
- Next by thread: Re: [tlug] question about shell scripting
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links