![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Array inside an array | manas_ranjan | UNIX for Advanced & Expert Users | 5 | 06-10-2008 02:25 PM |
| array | ccp | Shell Programming and Scripting | 3 | 02-26-2008 03:19 AM |
| I need help with an array! | djsal | Shell Programming and Scripting | 1 | 11-28-2007 11:26 AM |
| create array holding characters from sring then echo array. | rorey_breaker | Shell Programming and Scripting | 5 | 09-28-2007 08:42 AM |
| Do I need an array here? | TheCrunge | Shell Programming and Scripting | 5 | 04-19-2005 03:20 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
using array
hello experts
can u tell me please how i have a text file . In third field of a file there are names like abb asa asas asasas i just want to store the third filed of a file in an array. and to display the result in a same order using for loop through array can any one tell me how to do this in the shell script take care bye shary |
|
|||||
|
With bash:
Code:
$ cat file
filed1 filed2 field3_1 field4
filed1 filed2 field3_2 field4
filed1 filed2 field3_3 field4
filed1 filed2 field3_4 field4
filed1 filed2 field3_5 field4
filed1 filed2 field3_6 field4
filed1 filed2 field3_7 field4
$ a=($(cut -d" " -f3 file))
$ i=0;until((i>=(${#a}-1)));do echo ${a[i]};((i+=1));done
field3_1
field3_2
field3_3
field3_4
field3_5
field3_6
field3_7
Code:
awk '{x[NR]=$3}
END{for(i=1;i<=NR;i++)print x[i]}' file
|
|
||||
|
using array
hi experts
thank you so much for your cooperation i really appreciate your quick response. Regards, Shary |
| Sponsored Links | ||
|
|