Trick to ignore space in folder name


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Trick to ignore space in folder name
# 1  
Old 01-18-2008
Trick to ignore space in folder name

Hello All,

I am getting error while passing a folder name that has space to the cmd line argument.

sh log_delete2.sh "/home/kumarpua/TESTARTIFACTS/atf-chix/ATF-subversion-dev/ssenglogs/A RM"

log_delete2.sh: line 17: cd: /home/kumarpua/TESTARTIFACTS/atf-chix/ATF-subversion-dev/ssenglogs/A: No such file or directory
expr: non-numeric argument

ls: /home/kumarpua/TESTARTIFACTS/atf-chix/ATF-subversion-dev/ssenglogs/A: No such file or directory




Can any one pls suggest how to ignore the space in folder name.....

Regards,
Pulkit
# 2  
Old 01-18-2008
Quote:
Originally Posted by pulkit
Hello All,

I am getting error while passing a folder name that has space to the cmd line argument.

sh log_delete2.sh "/home/kumarpua/TESTARTIFACTS/atf-chix/ATF-subversion-dev/ssenglogs/A RM"

log_delete2.sh: line 17: cd: /home/kumarpua/TESTARTIFACTS/atf-chix/ATF-subversion-dev/ssenglogs/A: No such file or directory
expr: non-numeric argument

ls: /home/kumarpua/TESTARTIFACTS/atf-chix/ATF-subversion-dev/ssenglogs/A: No such file or directory




Can any one pls suggest how to ignore the space in folder name.....

Regards,
Pulkit
It might be that you need to replace the existing code in order to take care of this problem. Can you show the code that is doing this.
# 3  
Old 01-21-2008
I believe that this is a bug in log_delete2.sh. Very often bug: you should always use apostrophes: "string with spaces, $HOME"=1 argument that is parsed, '$HOME xxx'=1 argument that is not parsed, string xxx $HOME=3 arguments that are parsed.
Most of the scripts I have seen have problems with such names/params Smilie
Do not try to pass directories like '/home/user/ directory with space as first character' - such scripts tends to do:
rm -rf $param
so it runs as
rm -rf /home/user
rm -rf directory
rm -rf with
rm -rf space
rm -rf as
rm -rf first
rm -rf character

Last edited by adderek; 01-21-2008 at 10:39 AM.. Reason: colors & missing details
# 4  
Old 01-21-2008
Hello,

Please do like this :
sh log_delete2.sh "/home/kumarpua/TESTARTIFACTS/atf-chix/ATF-subversion-dev/ssenglogs/A RM"

Inside the script you have to do like this

cd "$1"

If the directory /home/kumarpua/TESTARTIFACTS/atf-chix/ATF-subversion-dev/ssenglogs/A RM is exists then it will work.

Regards,
Thobias
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Move files from Space Folder to other folder

I want to move a folder with spaces from one folder to another. I have two folders like this, 1).RT_032-222 -4444-01/ 2). RT_032-555 -7777-01/ I want to move files from 2 to 1 through shell script.Here I want to assign this like a user defined variable like as Source branch... (2 Replies)
Discussion started by: kannansoft1985
2 Replies

2. Shell Programming and Scripting

Ignore Folder in Shell Script ?

Hi, I currently use a script to extract *.deb files located in a Directory called "/var/mobile/Media/Downloads" The Problem is howver I want the script to ignore the folder: "/var/mobile/Media/Downloads/New Debs and Files" (it shall NOT decompile any of the files in that folder. Here is... (2 Replies)
Discussion started by: pasc
2 Replies

3. HP-UX

Which Folder occupies more space?

Hi, What are the correct parameters to list folders size in MBs under a particular directory in HP-UX ? I know and commands but cannot get the output of folder sizes in MBs. (4 Replies)
Discussion started by: mohtashims
4 Replies

4. Shell Programming and Scripting

AWK FS with ignore space option

Hi, i have in a situation to get the variables which are having a "|" delimiter and each variable may or may not have spaces, so how can i skip the spaces on the string and print the string as it is. For example: line = "|Hello world|Hello|Hi Guys| read x y z <<<$(echo "$line" | awk -F"|"... (5 Replies)
Discussion started by: tprabhaker
5 Replies

5. Shell Programming and Scripting

ignore space regular expression

I just wrote a modsecurity rule that blocks execution on "cat /etc/passwd" from webshell. But when I use cat /etc/passwd it works. Ie when I add space after cat. What I need is a regular expression to ignore additional space than the first single space after cat. (2 Replies)
Discussion started by: anil510
2 Replies

6. UNIX for Dummies Questions & Answers

Copy multiple files with space to folder

Please help , I am in an urgent need, Please help nawk '{for(i=1;i<=NF;i++){printf("%s\n",$i)}}' filename | sed 's/.*com//' | nawk '/pdf/ {printf("F:%s\n",$0)}' | while read line; do mv $line /images/; done the above script works for without spaces but,My path is also having some space... (3 Replies)
Discussion started by: umapearl
3 Replies

7. Shell Programming and Scripting

find the folder with space in name.

A solaris server with SAMBA share folder. The PC users created many folders with space on it, I want to find them out, but not list its subfolders. For example, I have below folders Copy of ABC/efg/xy sa/Test again/xyt If I use command: find . -type d |grep " " I will list 6 folders, but... (2 Replies)
Discussion started by: rdcwayx
2 Replies

8. UNIX for Dummies Questions & Answers

Creating space in root folder

Hi , I was wondering if anyone knows any great ways for creating space in your Root Folder. My root folder was created with only 247.7MB & I found out that its now full & I was initially wondering how important the "thumbnails Folder" was & if it was alright to delete their contenses as I noticed... (2 Replies)
Discussion started by: Browser
2 Replies

9. Shell Programming and Scripting

space in folder name

hi my folder name is below FTP_DIR="/DATA/TEMP/PA Mthly and Qrty files" But when i am using the varaible in my ftp shel script i am getting the error '/DATA/TEMP/VA: The system cannot find the path specified please advice. thanks in advance sam (2 Replies)
Discussion started by: sam99
2 Replies

10. UNIX for Dummies Questions & Answers

space in perticular folder in unix

can any one tell me how to know the free space in perticular folder in unix. size in bytes/MB. thanks in adv. spandu (7 Replies)
Discussion started by: spandu
7 Replies
Login or Register to Ask a Question