Operating System - HP-UX
1753903 Members
10018 Online
108810 Solutions
New Discussion юеВ

Re: Space character in filename's

 
SOLVED
Go to solution
Co van Berkel
Regular Advisor

Space character in filename's

Hi,
How can I "list" and process filenames with space(s) in the filename in a shell script?

Help...

Rgrds CvB.
8 REPLIES 8
Co van Berkel
Regular Advisor

Re: Space character in filename's

Hi,

On a HP-UX 11.11 (11i v1) rp4440 server..

Rgrds CvB.
Chris Wilshaw
Honored Contributor

Re: Space character in filename's

You can do this using find;

find / -name "* *" -print

RAC_1
Honored Contributor

Re: Space character in filename's

ll -b
ll|cat -bv
ll|vis

Anil
There is no substitute to HARDWORK
john korterman
Honored Contributor

Re: Space character in filename's

Hi,
e.g. like this:

#!/usr/bin/sh
DIR_PATH="."
ls "$DIR_PATH" | while read filename
do
echo "$filename"
echo "process $filename"
done

The qouting will probably do the trick.

regards,
John K.
it would be nice if you always got a second chance
H.Merijn Brand (procura
Honored Contributor

Re: Space character in filename's

for i in *\ * ; do
process "$i"
done

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Co van Berkel
Regular Advisor

Re: Space character in filename's

Hi,
Thanks for the quick reactions.

But how to change one or more "spaces" in a filename to a other character "_".

I need to pass the filename from one script ot an other including some more params.

- script_a:
ls -1 /dir/

Start-loop

./script_b
End-loop

Rgrds CvB
H.Merijn Brand (procura
Honored Contributor
Solution

Re: Space character in filename's

for i in *\ * ; do
f=`echo "$i" | tr ' ' '_'`
process "$f"
./script_b "$f"
done

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Co van Berkel
Regular Advisor

Re: Space character in filename's

Thanks to all...

Rgrds CvB.