The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Checking for a file in file pattern before deleting it dsrookie UNIX for Dummies Questions & Answers 1 05-09-2008 05:29 PM
Command used for checking space occupied by files & sub-direc's inside a mount in %? weblogicsupport SUN Solaris 2 02-01-2008 07:00 AM
Error checking a file from previous file size stuck1 Shell Programming and Scripting 2 12-06-2007 08:39 AM
log file checking mpang_ Shell Programming and Scripting 1 05-02-2006 03:04 AM
Checking file size jkuchar747 UNIX for Dummies Questions & Answers 2 03-02-2005 02:34 PM

Closed Thread
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
  #1 (permalink)  
Old 03-01-2007
madhu_aqua14 madhu_aqua14 is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 16
checking for a space in a file name

hi members...

another new probs...
i need to check all the zip files in the server and check for a space or "`" in the file name and if found need to remove them and form a zip file.

i tried using grep command to check for a space but with out success also when i tried checking for "`" as its a special character its not recognisable in the script .. so need to have escape sequence i suppose ..

i need help to come out of this
please help
  #2 (permalink)  
Old 03-01-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958

Code:
while read file
do

#Following would have the clean name without such chars
#newfile=`echo "$file" | sed "s/[ \`]//g"`

mv $file `echo "$file" | sed "s/[ \`]//g"`

done < list_of_filenames_with_such_chars

  #3 (permalink)  
Old 03-01-2007
Raghuram.P Raghuram.P is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 44
Hi,
Try to use egrep as follows
ls *.zip | egrep -e '(" "|\`)'
This will find the files with space or ` in the file name.
If you want to search multiple directories try to use it with find..

Thanks
Raghu
  #4 (permalink)  
Old 03-01-2007
madhu_aqua14 madhu_aqua14 is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 16
finding space in file name

hi matrix...

plz cud u explain the command

mv $file `echo "$file" | sed "s/[ \`]//g"`

also when i execute this command
we got error
unexpected EOF while looking for matching ``'

please help
  #5 (permalink)  
Old 03-01-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
Quote:
Originally Posted by madhu_aqua14
hi matrix...

plz cud u explain the command

mv $file `echo "$file" | sed "s/[ \`]//g"`

also when i execute this command
we got error
unexpected EOF while looking for matching ``'

please help
Could you please post how you had executed the command, with your input, if possible ?

File with spaces and ` character are suppressed and the old file is renamed to new file
  #6 (permalink)  
Old 03-01-2007
madhu_aqua14 madhu_aqua14 is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 16
checking spaces

hi matrix

here is the file name
3`_1_01_au.zip

and the code

ls *.zip | while read file
do
echo $file
echo "$file" | sed "s/[ \`]//g"
mv $file `"$file" | sed "s/[ \`]//g"`
done

error : mv: missing file argument
and unexpected EOF while looking for matching ``'
  #7 (permalink)  
Old 03-01-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
try this

Code:
mv $file $( echo "$file" | sed "s/[ \`]//g" )

Closed Thread

Bookmarks

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 07:53 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