Shell Script Exercise

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Gerald Thurman
Date:  
To: plug-discuss
Subject: Shell Script Exercise
I wrote a command that moves all the files having
the permissions "rw-------" (i.e. 600) found in a
directory to a different directory. The command
has the following logic inside of a loop.

ls -l $filename | grep -q "^-rw-------" # line 1
[ $? -eq 0 ] && mv $filename $newdir

The command works, but I wanted to replace line #1 with a
single command eliminating the pipe. Initially, I thought the
'test' command would be sufficient, but it's not. Any ideas?

<sidebar>
For the curious... I wrote a C program named 'printmod'
that allows the command to read as follows.

[ "600" = `printmod $filename` ] && mv $filename $newdir

http://deru.com/~gdt/c/code/unix/printmod.c
</sidebar>
---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss