![]() |
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 |
| print all even lines of a txt file | ajp7701 | Shell Programming and Scripting | 1 | 04-17-2008 11:17 PM |
| print selected rows with awk | tonet | Shell Programming and Scripting | 6 | 09-27-2007 06:23 AM |
| How to print specific lines with awk | Bugenhagen | Shell Programming and Scripting | 10 | 08-16-2007 06:41 AM |
| How to print number of lines with awk ? | maheshsri | Shell Programming and Scripting | 1 | 11-18-2005 02:19 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hi everybody:
I try to print in new file selected lines from another file wich depends on the first column. I have done a script like this: Code:
lines=( "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "21" "31" "41" "51" "55" "57" "58" )
${lines[@]}
for lines in ${lines[@]}
do
awk -v target=$lines ' $1 == target print $0 ' file1 >> file2
done
Code:
./T-eff.sh: 42: Syntax error: "(" unexpected ------ where the line 42 correspond when I declare the array "lines"
![]() |
|
||||
|
Bash is the bourne again shell, the newer version of the bourne shell, or sh.
If you want bash, start your script with #!/bin/bash otherwise if no shell is selected sh will be used, and that doesn't support arrays as far as I know. |
|
||||
|
Code:
#!/bin/sh Code:
#!/bin/bash ![]() |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|