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
how to delete content in a file (delete content only) kittusri9 Shell Programming and Scripting 5 05-15-2008 02:12 PM
comparing content of 2 variables in script sam4now Shell Programming and Scripting 5 04-24-2008 03:42 PM
file moving based on file content melvyn.cochrane Shell Programming and Scripting 12 02-15-2008 06:10 AM
Using the content of a file in the name of another anriot Shell Programming and Scripting 2 09-18-2006 08:56 PM
transfer of specific file content to another file mem101 Shell Programming and Scripting 1 10-18-2005 03:01 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 11-30-2006
Rock Rock is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 23
Put content of file into variables

How to put a line of strings (with some white spaces in between) from a file into variables?

I have tried the following codes. However, the content is cut by space (not by line)


for i in `cat ${source_file}`
do
echo $i
done


Please comment. Thanks.
  #2 (permalink)  
Old 11-30-2006
ask.jackal ask.jackal is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 24
IFS=""
for i in `cat ${source_file}`
do
echo $i
done

John Arackal
  #3 (permalink)  
Old 12-01-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
Here is a solution without changing the IFS and getting rid of UUOC.


Code:
while read line
do
  echo "$line"
done < ${source_file}

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 09:22 PM.


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