The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
spaces in filenames Bab00shka Shell Programming and Scripting 8 09-30-2008 03:13 PM
perl script to list filenames that do not contain given string royalibrahim Shell Programming and Scripting 21 04-22-2008 02:55 PM
spaces in filenames, for do naviztirf Shell Programming and Scripting 4 10-17-2007 06:08 PM
Unix filenames and spaces x96riley3 Shell Programming and Scripting 2 01-31-2007 07:07 PM
spaces in filenames Hitori Shell Programming and Scripting 4 07-04-2006 05:35 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-18-2008
hikrishn hikrishn is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 4
How to list filenames with spaces in shell script

Hi,

I want to list all the files matching in a directory directory given below
Here one of the folder has a space in the path.

/MAS02/RMS/WBDev/Krishna/Krishna Mohan/FMSplitByKeyAfterChanges1000075383.fileman.*.txt.out.1000075383.0

The following works from command line
********************************

ls '/MAS02/RMS/WBDev/Krishna/Krishna Mohan/'FMSplitByKeyAfterChanges1000075383.fileman.*.txt.out.1000075383.0

I am trying to do the same stuff from shell script ,but it is not working.
Pls suggest
********

#!/bin/ksh -x
#
in="/MAS02/RMS/WBDev/Krishna/Krishna Mohan/FMSplitByKeyAfterChanges1000075383.fileman.*.txt.out.1000075383.0"
dirName=`dirname "$in"`
fileName=`basename "$in"`
newfileslist=\'$dirName/\'$fileName
filecnt=`ls $newfileslist | wc -l `

It gives an error like this, when I execute above script
****************************************

+ ls /MAS02/RMS/WBDev/Krishna/Krishna Mohan/FMSplitByKeyAfterChanges1000075383.fileman.*.txt.out.1000075383.0
+ wc -l
ls: /MAS02/RMS/WBDev/Krishna/Krishna: No such file or directory
ls: Mohan/FMSplitByKeyAfterChanges1000075383.fileman.*.txt.out.1000075383.0: No such file or directory
+ fcnt=0

Last edited by hikrishn; 06-18-2008 at 05:24 PM.. Reason: small correction to error message
 

Bookmarks

Tags
awk, awk trim, trim, trim awk

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:27 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0