Hi
I am faceing a problem with a space in file name.
I want to write a script which will open a file that file contain others file name, among them few file name contain space.
>cat checkfile
file1
file2
new file
file no
Here the file 'new file' and 'file no' contain space.When i trying to print contain of the file 'new file' from for loop it is giving error like,
cat: new: No such file or directory
cat: file: No such file or directory
cat: file: No such file or directory
cat: no: No such file or directory
Please give suggestion how do i resolve.Thanks in advance.
Thanks,
-ASK
9 9338
>cat checkfile
file1
file2
new file
file no
Here the file 'new file' and 'file no' contain space.When i trying to print contain of the file 'new file' from for loop it is giving error like,
cat: new: No such file or directory
cat: file: No such file or directory
cat: file: No such file or directory
cat: no: No such file or directory
Try this: - >cat checkfile
-
file1
-
file2
-
new\ file
-
file\ no
Note the backslashes - I'm escaping the space. I think, this way it should work fine.
Greetings,
Nepomuk
No It is not wroking.
As i told you i am getting problem in for loop.
This chechfile is the input in for loop,
As the for loop iterates based on space so \, ", ' anything is not wroking.
Pls, try like this open that checkfile in for loop and then trying to print the containt of each file from checkfile.
How do i resolve .Thank in advance.
-Ashok
No It is not wroking.
As i told you i am getting problem in for loop.
This chechfile is the input in for loop,
As the for loop iterates based on space so \, ", ' anything is not wroking.
Pls, try like this open that checkfile in for loop and then trying to print the containt of each file from checkfile.
How do i resolve .Thank in advance.
-Ashok
Well, it's difficult to find a solution without having the code. Could you post the relevant parts of this shell script?
Also, is the error message still the same?
Greetings,
Nepomuk
Error Msg i have posted at first place.
Just a for loop, input is the checkfile(which contain few file names )
Inside using cat for each file.
Thats it. You try, I am sure u will also face the same problem.
There must be some way to use files and folders which contain space in script.
Best Regards,
Ashok
Error Msg i have posted at first place.
OK, so it's still the same error message. Exactly the same?
Just a for loop, input is the checkfile(which contain few file names )
Inside using cat for each file.
Thats it. You try, I am sure u will also face the same problem.
That's not the point. We want to make your code work, so please post your code! I'm sure, we'll be able to solve the problem then.
Greetings,
Nepomuk
don't use for loop with cat. Use while read loop instead to iterate a file -
while read line
-
do
-
# echo $line
-
done < file
-
What is the difference by reading with for to while loop.
Can you please elaborate a little.
Thanks for your suggestion.
I found out the above solution first convert the space before for loop to some other rearly used character. then inside for loop do the opposite by sed command.
Thanks for your time.
-Ask
functions wise, there is no difference. They are just loops. Syntactically, they are different. PLease look through the bash reference manual for more information. I am just only advising on the caveats you will encounter when using a for cat loop to iterate a file. Special care need to be taken to ensure white spaces is escaped properly.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mark Miller |
last post by:
I have a scheduled job that uses different XSL templates to transform XML
and save it to disk. I am having problems with the code below. The problem
shows up on both my development machine (Windows...
|
by: alain |
last post by:
Good morning to you all,
The problem : i use the shell command and i used, with W98, to use the DOS
name when there was a space in the file / folder name ( ex : Program~1 for
Program Files). With...
|
by: adgnews |
last post by:
I have a problem converting a program from Vb.net VS2003 to VS2005. I
process a xml-file with an inline schema. In 2003 no problem. In 2005 I
have 2 problems:
1) BIG space="preserve" problem....
|
by: Dave G |
last post by:
I know this is an old favourite but I can't find a simple answer to a
simple question.
I'm trying to run this:
shell("c:\program files\pkware\pkzipc\pkzipc.exe -ext " & myPath &
myZIPFile & "...
|
by: snow |
last post by:
Hi All,
I noticed if file path has a white space, for example "C:\my document
\test.txt", the function File.Exists(filePath) always return false in
release mode. How could I make this function...
|
by: kvnsmnsn |
last post by:
I've written the following Javascript file that includes an input text
field and an output text field, the latter of which is initialized to
zero. Each time the user enters a number in the input...
|
by: skyy |
last post by:
Hi.. i have a string that i would want split on a single blank space only.
eg.
$string = File: abc.txt
using split with white space i can get the name of the file : abc.txt
However i run...
|
by: lawrence k |
last post by:
I've got a music studio for a client. Their whole studio is run with
Macintosh computers. Macintosh computers allow file names to have open
white spaces, such as "animal hospital.mp3".
I have a...
|
by: Joseph J. Kesselman |
last post by:
Gabe wrote:
You can do exactly that, exactly as you've shown it:
<nameJohn Smith</name>
But...
Now you aren't talking about XML -- you're talking about the behavior of
the tool you're...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |