How to read the filenames with space character in it


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to read the filenames with space character in it
# 1  
Old 05-14-2011
How to read the filenames with space character in it

Hi,
My Requirement is to read the filenames which possess space charatcer in it and pass the same file name to the other shell script as input parameter.
Please provide your valuable suggestion.
# 2  
Old 05-14-2011
One way is to enclose the filenames in quotes.
# 3  
Old 05-14-2011
Hi,
This is wat i am doing in the code
For file_name in *\ *
do
test.sh file_name
done


files in the folder
test 1.csv
test 2.csv
test3.csv

please provide a suggestion
# 4  
Old 05-14-2011
Please use code tags
Code:
for file_name in *\ *
do
     test.sh "$file_name"
done

# 5  
Old 05-14-2011
Hi,
I can read the file names properly.However while passing the file names as a parameter it is not taking the complete name.
I tried with above solution and its not working
# 6  
Old 05-14-2011
Frans also introduced double quotes around the variable reference. You need those to preserve the space in the file name.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read character by character in line in which space is also included

Hi friend, I have one file , and i want to read that file character by character. I need this script in ksh. while using read option with -n1 am getting error. while read -n1 c read has bad option And if i am using below script, then if in a line has space like this ( Pallvi mahajan)... (10 Replies)
Discussion started by: pallvi_mahajan
10 Replies

2. Shell Programming and Scripting

Read filenames in sorted order

Hi , My requirement is to scan a directory for file names with LTR.PDF* and send those files via ftp to another server one by one. Now the the problem is file names are like LTR.PDF ,LTR.PDF1 ,LTR.PDF2.....LTR.PDF10..upto 99 and these needs to be sent in sorted order. is there a way to get... (10 Replies)
Discussion started by: nishantrk
10 Replies

3. Shell Programming and Scripting

read the text file and print the content character by character..

hello all i request you to give the solution for the following problem.. I want read the text file.and print the contents character by character..like if the text file contains google means..i want to print g go goo goog googl google like this Using unix Shell scripting... without using... (1 Reply)
Discussion started by: samupnl
1 Replies

4. Shell Programming and Scripting

Can I read a file character by character?

Hello all respected people, Can i read a file character by character without using sed,awk and perl commands. Thanks in advance. (4 Replies)
Discussion started by: murtaza
4 Replies

5. Shell Programming and Scripting

read in a file character by character - replace any unknown ASCII characters with spa

Can someone help me to write a script / command to read in a file, character by character, replace any unknown ASCII characters with space. then write out the file to a new filename/ Thanks! (1 Reply)
Discussion started by: raghav525
1 Replies

6. Shell Programming and Scripting

move filenames with to another filename without the last character ~

Hi, I need to move filenames with the following format below into filenames without the ~ like sample below. I hope you can help me create a simple unix script that will do this. Thanks in advance! move filename from: AIRS20081225-235641.BSP~ AIRS20081225-235648.BSP~ AIRS20081225-235640.BSP~... (3 Replies)
Discussion started by: ayhanne
3 Replies

7. UNIX for Dummies Questions & Answers

read a variable character by character, substitute characters with something else

im having trouble doing this: i have a variable with 2 characters repeating e.g. aababbbaaaababaabbaabbba is there a way i can search the variable for a's and b's and then change a's to b's and b's to a's? im guessing its like getting the 1's compliment of the string im doing this in... (2 Replies)
Discussion started by: vipervenom25
2 Replies

8. Shell Programming and Scripting

Can i read a file character by character

How to read character by character using awk (6 Replies)
Discussion started by: karnan
6 Replies

9. Shell Programming and Scripting

read list of filenames from text file, archive, and remove

I posted a week ago regarding this scripting question, but I need to revisit and have a few more questions answered.. User cfajohnson was extremely helpful with the archive script, but clarification on my part is needed to help steer the answer in a direction that works in this particular... (5 Replies)
Discussion started by: fxvisions
5 Replies

10. Shell Programming and Scripting

How to read filenames with space in between

Hi All, I need to read filenames with space in between in a for loop like Integration of utility projects Integration of hdf projects I copied these files from a windows system and as you know windows filename has spaces in between them. But while unix is reading the filename in a for... (12 Replies)
Discussion started by: dayanandra
12 Replies
Login or Register to Ask a Question