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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
[BASH - KSH] Passing array to a function ripat Shell Programming and Scripting 3 04-17-2008 05:17 AM
output of an array ragha81 Shell Programming and Scripting 3 03-22-2007 12:30 PM
bash array gubten Shell Programming and Scripting 1 12-08-2006 12:47 PM
How can i read array elements dynamically in bash? haisubbu UNIX for Dummies Questions & Answers 1 08-28-2006 11:19 PM
bash array passed to oracle satnamx Shell Programming and Scripting 0 04-09-2006 04:01 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-14-2008
Registered User
 

Join Date: Jan 2008
Posts: 25
bash:awk output into an array

Hi,

I have a file

1:apple orange:one
2:banana:two
3:cherry:3

When I do awk -F: ' { print $2 } ' file

apple orange
banana
cherry

Now, when i redirect awk output to the file it has issue with strings
#!/bin/bash
FILEA=file
A=(`awk -F: ' { print $2 } ' $FILEA `)

echo ${A[0]}
It gives the output
apple
banana
cherry

Somehow, I lost orange along the way.

Thanks

Last edited by zazzybob; 03-14-2008 at 04:19 AM. Reason: Smilies disabled.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-14-2008
Moderator
 

Join Date: Dec 2003
Location: /ksh93
Posts: 880
Add the statement IFS="" before the A= statement
Reply With Quote
  #3 (permalink)  
Old 03-16-2008
Registered User
 

Join Date: Jan 2008
Posts: 25
thank you much
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:35 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0