The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Reading a line including spaces aksarben UNIX for Dummies Questions & Answers 1 09-19-2007 07:39 PM
Please Help!! Reading a string of text with concurrent spaces into a shell variable mjs3221 UNIX for Advanced & Expert Users 1 08-16-2006 02:17 PM
prob with spaces in reading a file Amardeep Shell Programming and Scripting 2 05-23-2006 11:54 AM
Reading file names from a file and executing the relative file from shell script anushilrai Shell Programming and Scripting 4 03-10-2006 05:25 AM
Strip leading and trailing spaces only in a shell variable with embedded spaces jerardfjay Shell Programming and Scripting 6 03-07-2005 02:24 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-27-2008
jekl5 jekl5 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 2
Reading a file using sh with spaces in filename

Hi

I am trouble parsing through a file with spaces in the filename. I need to grab "supportIDPS/SCM/windows_install/file groups/dds.fgl" and then do a md5sum on it. I am using sh.
Any help is appreciated.


Here is an example of the input file:
7eedbc9f7902bf4c1878d9e571addf9a supportIDPS/SCM/windows_install/file groups/dds.fgl
341001e442a16435a4dca02ce0fb1fa6 supportIDPS/SCM/windows_install/file groups/default.fdf
a06707d4ff14b9718ad1a876689ae3ad supportIDPS/SCM/windows_install/file groups/inf.fgl
  #2 (permalink)  
Old 02-27-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
Try the cut command.

With a space as fieldseperator you can print the 2nd and the 3th column. Check the manpage of cut.


Regards
  #3 (permalink)  
Old 02-27-2008
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
  
 

Join Date: Apr 2002
Location: Italy
Posts: 370
As told by Franklin52, you can use:

Code:
cut -f2- -d ' ' input_file
  #4 (permalink)  
Old 02-27-2008
jekl5 jekl5 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 2
I figured out two solutions:

Solution 1:
while read line ;do
CUT=`echo "$line" | sed 's/^.* //g'`
md5sum $CUT
done < INFPUT_FILE

Solution 2:
while read checksum file ;do
md5sum "$file"
done < INPUT_FILE

Thanks everyone
  #5 (permalink)  
Old 02-29-2008
adderek adderek is offline
Registered User
  
 

Join Date: Sep 2007
Location: Poland
Posts: 110
Try searching for my posts - I gave some instructions about this.
But in short way:

USE:
"${variable}"
instead of
$variable
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 11:23 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