LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 02-10-2009, 11:25 AM   #1
mitramcc
LQ Newbie
 
Registered: Feb 2009
Posts: 3

Rep: Reputation: 0
problem exporting result of awk to an array...


cmd=$1 # first argument
str=( $2 ) # second argument
pattern=$3 # third argument

for (( i=0 ; i<${#str[*]} ; i=i+1 ))
do
echo ${str[${i}]}|awk -F $pattern '{print NF-1}'
var[${i}]=`${str[${i}]}|awk -F $pattern '{print NF-1}'
done

echo ${var[*]}



when i do :

:~/Desktop$ ./tst.sh -r 'asdasd asdasd' asd
the result is
2
2

-----------------------------------------------
the var stills empty :/...

can somebody help me :/ i am to noob :/

Last edited by mitramcc; 02-10-2009 at 11:45 AM.
 
Old 02-10-2009, 11:32 AM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
You have a space between the hyphen and the F argument, no closing single quote in the first awk line, and no third argument to use as the separator.

Last edited by jschiwal; 02-10-2009 at 11:34 AM.
 
Old 02-10-2009, 11:47 AM   #3
mitramcc
LQ Newbie
 
Registered: Feb 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jschiwal View Post
You have a space between the hyphen and the F argument, no closing single quote in the first awk line, and no third argument to use as the separator.
the first to mistakes it was error of copy, bc i had that right :/...

about the third, the third argument isn't the asd?
1st -r
2nd asdasd asdasd
3rd asd

thx
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
using awk on a awk result jpgauvin Programming 1 12-15-2008 03:57 AM
Best awk array tutorial bijit1709 Programming 1 01-25-2008 01:04 AM
Storing the result of execvp to a char array in C kponenation Programming 3 12-14-2005 05:45 PM
cannot export result from awk into a variable in a bash script Emmanuel_uk Linux - Newbie 4 03-07-2005 01:54 AM
How to return values into an array using awk Helene Programming 1 05-01-2004 10:05 PM


All times are GMT -5. The time now is 12:13 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration