Mailinglist Archive: opensuse-programming (98 mails)

< Previous Next >
Re: [suse-programming-e] Simple question about shell scripting on SuSE 8.0
  • From: Zoltan Szecsei <zoltans@xxxxxxxxxxxxxx>
  • Date: Sat, 14 May 2005 08:10:34 +0200
  • Message-id: <4285965A.3030603@xxxxxxxxxxxxxx>
Hi Peeps,

Can I please just pick up on this thread....

If the filename has spaces in it (eg: "Full\ Length\ Movies") how can I get the entire filename into $i because what is happening is, on first iteration $i is "Full" , on 2nd it is "Length" etc...

TIA,
Zoltan



Jerry Feldman wrote:
On Thursday 05 May 2005 2:37 am, robert guru wrote:

Hallo,
I m a shell scripting newbie, and i m trying to create a shell script
that search for some files named 'script', those files are located in the
subdirectory of a directory named "folder", and for each file founded, i
have to show the directory (full path) where the file was founded and pipe the file to some program.
the script must be something like that:

for each file found in the subdirectory tree of "folder"
do
"show the full path where the file was found, without the file name,
like /root/folder/images"
enter this directory already showed ($cd directory)
"pipe the file to a program"
done

A patrick mentioned, find should work, but here is a bash script that does what you want. The script is not very elegant as I threw it together. In this case, sname is a variable containing the name of a file that has "script" in the name. #!/bin/bash
for i in $(ls -p)
do
case $i in
*/) cd $i; pth=$PWD;
for sname in $(ls)
do
case $sname in
*script*) echo "$sname found in $pth";;
esac
done
cd ..;;
esac
done


--

==================================
Geograph (Pty) Ltd
P.O. Box 31255
Tokai
7966
Tel: +27-21-7018492
Mobile: +27-83-6004028
==================================


< Previous Next >