LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-31-2012, 02:33 PM   #1
vicky007aggrwal
Member
 
Registered: Aug 2012
Posts: 95

Rep: Reputation: Disabled
space in file name Error


Can someone please suggest how to print out the names of files having space in between them.

I am running the following for loop , but the thing is it is treating space delimiter between file names as new file ......please help

*************************************************

>>>>>>>>>ls -lrt
total 0
-rw-r--r--. 1 root root 0 Oct 31 11:31 file 3
-rw-r--r--. 1 root root 0 Oct 31 11:31 file 2
-rw-r--r--. 1 root root 0 Oct 31 11:31 file 1

>>>>>for i in `ls`; do echo $i;echo "****"; done
file
****
1
****
file
****
2
****
file
****
3
****
 
Old 10-31-2012, 02:47 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
In a previous thread it was suggested to prefer "while" over "for" loops. See if you can deal with things using:
Code:
find /path/ type f -iname file\* | while read ITEM; do
 doSomething "${ITEM}"
..

* In previous threads you have also been made aware of mywiki.wooledge.org and the Advanced Bash Scripting Guide. I'm going to add a few links in the hope you read and consult them:
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.tldp.org/LDP/Bash-Beginne...tml/index.html
http://www.gnu.org/software/bash/man...ode/index.html
http://www.grymoire.com/Unix/Sh.html
http://www.tldp.org/LDP/abs/html/
http://mywiki.wooledge.org/BashFAQ
http://mywiki.wooledge.org/BashPitfalls
 
Old 10-31-2012, 02:54 PM   #3
vicky007aggrwal
Member
 
Registered: Aug 2012
Posts: 95

Original Poster
Rep: Reputation: Disabled
???????????
 
Old 10-31-2012, 02:57 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
Also mark your own threads you replied to today as "solved" if they are and don't post this kind of "????" nonsense.
 
Old 10-31-2012, 03:02 PM   #5
vicky007aggrwal
Member
 
Registered: Aug 2012
Posts: 95

Original Poster
Rep: Reputation: Disabled
Thankz for ur heartfelt comments .. I didnt understand that y written ?..
 
Old 10-31-2012, 04:08 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
Quote:
Originally Posted by vicky007aggrwal View Post
for i in `ls`; do echo $i;echo "****"; done
Code:
find /path/ type f -iname file\* | while read ITEM; do echo "${ITEM}"; echo "****"; done
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Move file names with space to other directory with different file name with space pradeepdee6 Linux - Newbie 9 08-08-2012 10:19 AM
"Not sufficient disk space, downloaded file interrupted" error, PL 421 (frugal)... Benny7440 Linux - Newbie 2 11-28-2009 10:11 PM
not enough file system space error Fredsnet Solaris / OpenSolaris 9 01-06-2008 11:02 PM
Printer Error - "insufficient file space" adamslaw Linux - Newbie 1 02-22-2005 12:27 PM
Large tar file taking huge disk space in ext3 file system pcwulf Linux - General 2 10-20-2003 08:45 AM


All times are GMT -5. The time now is 01:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration