03-23-2009
Quote:
Originally Posted by
vidyadhar85
you mean you wanna find files like "log_*[0-9]"??
exactly
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Is it possible for find to match on multiple arg's. Basically, I would like to be able to match on name and atime. Basically I want something like:
find . -atime +31 <AND> -name *.log -exec rm -f {} \;
Thanks (2 Replies)
Discussion started by: 98_1LE
2 Replies
2. UNIX for Dummies Questions & Answers
:D i am looking through the man pages of the find command and I have found the -printf and fprintf section.. .
I tried this command and got an error
find -follow -newer 'date.file' -printf %f file1
i keep getting a %f in directory listing and no input into file1
according to the manpages %f... (2 Replies)
Discussion started by: moxxx68
2 Replies
3. Shell Programming and Scripting
Hi Guys,
Do you know how can I find files with modificatioin time less than 30 MINUTES using the find utility?
Or if u have any other mechanism to find it using script, I'll appreciate it.
Thanks! (5 Replies)
Discussion started by: marlonus999
5 Replies
4. UNIX for Dummies Questions & Answers
I have a file, but I don't know this file is stored in which directory, if I use 'find' command to search this file, is it work?
which option I use?
find filename? (2 Replies)
Discussion started by: wendyz
2 Replies
5. Shell Programming and Scripting
hey guys!
I need to find in a specific directory and its sub-directories a file thats passed has a argument, and print it has like a ls -l command! the problem is how do i print has a ls command but instead only the file name in the end, also the directory where its insered!
ex:
Want... (2 Replies)
Discussion started by: Shinni
2 Replies
6. UNIX for Dummies Questions & Answers
All,
For some reason I can't figure out why I can't wildcard my find statement to check for anything with a wildcard after. I can before the -name but not after.
ie. find . -name *test works
but find . -name test* gives me the error: find: paths must precede expression
Usage: find ... (1 Reply)
Discussion started by: markdjones82
1 Replies
7. UNIX for Dummies Questions & Answers
I was using this find command to search for this string
find /usr/reports -name '*.txt' -type f -exec grep -l tbl_out:add_19 {} \; > /usr/work/junk.txt
My question is, if I want to search another type of file extension besides '*.txt'
how can I include it on the same line to say something... (5 Replies)
Discussion started by: NycUnxer
5 Replies
8. Shell Programming and Scripting
Hi all,
I want to use find to 'find' files older than a file.
The command I have come up with so far is
find . -type f ! -newer filename -print | grep -v filename
If I dont use the -v then the filename is included in the output
is there a better way of formulating this command... (1 Reply)
Discussion started by: jonnyd
1 Replies
9. UNIX for Dummies Questions & Answers
I need to find all files with file names starting with
alert
and ending with
.log
I mean, the following files should be returnrned
alertTST.log
alertabcdefgh.log
How can i do this ? (4 Replies)
Discussion started by: kraljic
4 Replies
10. UNIX for Dummies Questions & Answers
Hi,
Is there an option to run ls to only show files owned by the current user? Currently doing ls | awk | grep for the user.
If I use find and -user ${username}, I am getting Permission denied messages on some directories and am currently re-directing those messages as 2>/dev/null. Is that... (2 Replies)
Discussion started by: newbie_01
2 Replies
LEARN ABOUT DEBIAN
shell-quote
SHELL-QUOTE(1p) User Contributed Perl Documentation SHELL-QUOTE(1p)
NAME
shell-quote - quote arguments for safe use, unmodified in a shell command
SYNOPSIS
shell-quote [switch]... arg...
DESCRIPTION
shell-quote lets you pass arbitrary strings through the shell so that they won't be changed by the shell. This lets you process commands
or files with embedded white space or shell globbing characters safely. Here are a few examples.
EXAMPLES
ssh preserving args
When running a remote command with ssh, ssh doesn't preserve the separate arguments it receives. It just joins them with spaces and
passes them to "$SHELL -c". This doesn't work as intended:
ssh host touch 'hi there' # fails
It creates 2 files, hi and there. Instead, do this:
cmd=`shell-quote touch 'hi there'`
ssh host "$cmd"
This gives you just 1 file, hi there.
process find output
It's not ordinarily possible to process an arbitrary list of files output by find with a shell script. Anything you put in $IFS to
split up the output could legitimately be in a file's name. Here's how you can do it using shell-quote:
eval set -- `find -type f -print0 | xargs -0 shell-quote --`
debug shell scripts
shell-quote is better than echo for debugging shell scripts.
debug() {
[ -z "$debug" ] || shell-quote "debug:" "$@"
}
With echo you can't tell the difference between "debug 'foo bar'" and "debug foo bar", but with shell-quote you can.
save a command for later
shell-quote can be used to build up a shell command to run later. Say you want the user to be able to give you switches for a command
you're going to run. If you don't want the switches to be re-evaluated by the shell (which is usually a good idea, else there are
things the user can't pass through), you can do something like this:
user_switches=
while [ $# != 0 ]
do
case x$1 in
x--pass-through)
[ $# -gt 1 ] || die "need an argument for $1"
user_switches="$user_switches "`shell-quote -- "$2"`
shift;;
# process other switches
esac
shift
done
# later
eval "shell-quote some-command $user_switches my args"
OPTIONS
--debug
Turn debugging on.
--help
Show the usage message and die.
--version
Show the version number and exit.
AVAILABILITY
The code is licensed under the GNU GPL. Check http://www.argon.org/~roderick/ or CPAN for updated versions.
AUTHOR
Roderick Schertler <roderick@argon.org>
perl v5.8.4 2005-05-03 SHELL-QUOTE(1p)