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:37:40 +0900 (JST)
- From: Curt Sampson <cjs@example.com>
- Subject: Re: [tlug] question about shell scripting
- References: <43640.210.168.237.209.1169712799.squirrel@example.com>
On Thu, 25 Jan 2007, scott@example.com wrote:
So first I get a list of users:
awk -F: '{ print $1 }' /etc/shadow
In general, you'd want to use /etc/passwd; isn't /etc/shadow readable only by root? Though it probably doesn't matter in this case, since you no doubt need to be root to run your particular script.
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.
It's a list of names separated by whitespace.
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
You forgot a do, from the looks of it. This works for me:
for i in $(awk -F: '{print $1}' /etc/passwd); do echo $i done
cjs -- Curt Sampson <cjs@example.com> +81 90 7737 2974
- References:
- [tlug] question about shell scripting
- From: scott
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Networking two Linux computers harder than Linux to Windows?
- Next by Date: Re: [tlug] question about shell scripting
- Previous by thread: Re: [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