![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Storing commands in $variables. | Paulw0t | Shell Programming and Scripting | 7 | 08-08-2008 02:42 PM |
| Storing data of files | Fr0z3n999 | UNIX for Dummies Questions & Answers | 1 | 12-09-2006 06:47 PM |
| first row data into variables | u263066 | Shell Programming and Scripting | 1 | 08-14-2006 04:54 AM |
| Splitting data file | ctcuser | Shell Programming and Scripting | 4 | 01-08-2005 06:04 AM |
| awk - storing data in variables | 2nilotpal | Shell Programming and Scripting | 7 | 04-16-2004 02:32 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
I have a file in the given format: |aaa |hhh |fat hat chat |make sure I need to get store in a variable,say 'error' the value of the string 'fat hat chat' In short, echo $error should give the result fat hat chat Is this possible using awk? Also, can this be split.For example, I have to store the value of the string (fat hat chat) in to two variables.Say, error1 and error2 (Given field width is predefined) i.e error1=fat ha error2=h chat Thanks in advance Js |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
I have got the answer for my first question:
sed '1q' 1psql.out | awk -F"|" '{print $3}' ( I found this from the forum it self) But can some one help me with teh second part??? Thanks in advance Js |
|
#3
|
|||
|
|||
|
Dear jisha,
try this to get the value of "error=hat fat chat", use this awk -F'|' '{print $3}' filename to split a value, try this split($3,a,<seperator of the value>) gud luk Regards, Pankaj |
|
#4
|
|||
|
|||
|
Thanks for ur time Pankaj.
Can u please explain me what the 'a' and separator of the value stands for? I searched in the man page .. But didnt understand any thing .. Regards, Js |
|
#5
|
|||
|
|||
|
Quote:
Can any one tell me the solution for the same question when the given file has fields not separated by the | ??? Thanks in advance Js |
|
#6
|
|||
|
|||
|
Dear Jisha,
split($3,a,<seperator of the value>) here a is the array variable. u can use error instead of a then print like this print a[1] print a[2] u'll cum to know the thing Regards, Pankaj |
|
#7
|
|||
|
|||
|
hi there! (i'm at SunOS 5.9)
i'm trying to split a string with *split*, but i can't. for example: in shell i do: $ string='hi go bye' $ then i try: awk 'split($string, strings, " ")' (and a get the following) $ awk: syntax error near line 1 $ awk: illegal statement near line 1 i've tried a lot of choices, with files and more, and i can't get what's going on. how can i make it work? |
|||
| Google The UNIX and Linux Forums |