Re: Scripting
- From: "Calab" <myspam@xxxxxx>
- Date: Mon, 31 Dec 2007 06:36:03 GMT
#!/bin/bash
for i in $(command)
do
j=$(echo "$i" | cut -f4)
k=$(echo "$i" | cut -f3)
[ "$j" = "busy" ] && syscheck "$k"
done
#
where "command" gives your table, "cut" assumes tabs are the column
delimiters. - man cut
For some reason, $i does not contain the complete line. It only contains one
column...
Tried a very simple run and you can see that each line output by the ls -l
command is split up.
bash-2.05$ for i in $(ls -l) ; do(echo $i ) ; done
total
2349
lrwxrwxrwx
1
root
root
9
Nov
27
15:01
bin
->
../usr/bin
drwxr-xr-x
2
root
root
512
Dec
4
12:01
cdrom
-rw-------
1
root
other
671216
Dec
3
09:38
core
drwxr-xr-x
FWIW, I just realized that this is actually running on SunOS:
bash-2.05$ uname -a
SunOS ov2co.cg 5.9 Generic_122300-11 sun4u sparc SUNW,Sun-Fire-V240
.
- Follow-Ups:
- Re: Scripting
- From: Chris Elvidge
- Re: Scripting
- References:
- Scripting
- From: Calab
- Re: Scripting
- From: Chris Elvidge
- Scripting
- Prev by Date: Re: Scripting
- Next by Date: Re: man pages through konqueror
- Previous by thread: Re: Scripting
- Next by thread: Re: Scripting
- Index(es):
Relevant Pages
|