![]() |
|
|
|
|
|||||||
| 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 |
| Regardign strtok() output directing to 2-D string array | SankarV | High Level Programming | 3 | 04-28-2008 06:48 AM |
| bash:awk output into an array | phamp008 | Shell Programming and Scripting | 2 | 03-16-2008 02:14 AM |
| create array holding characters from sring then echo array. | rorey_breaker | Shell Programming and Scripting | 5 | 09-28-2007 05:42 AM |
| output of an array | ragha81 | Shell Programming and Scripting | 3 | 03-22-2007 01:30 PM |
| formating array file output using perl | seismic_willy | Shell Programming and Scripting | 4 | 03-21-2007 11:23 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#8
|
|||
|
|||
|
depending on the shell you are using
Code:
# set -- $array # echo $6 Code:
# result=`awk 'NR==6{print}' list4.txt`
# echo "this is my 6th item : $result"
|
| Forum Sponsor | ||
|
|
|
#9
|
|||
|
|||
|
Hi,
My shell is tcsh, What I am looking for is, array=`awk '{print $1}' /users/jon/list4.txt` array2=`awk '{print $1}' /users/jon/list5.txt` If value in array[] Not equal array2[] then echo value of arra[] >> ~/noval.txt can I do this? Thanks Amit |
|
#10
|
|||
|
|||
|
Code:
# awk '{print $1}' /users/jon/list4.txt > 1.txt
# awk '{print $1}' /users/jon/list5.txt > 2.txt
# diff 1.txt 2.txt
# echo $? #use this to check whether the 2 files are different.
|
|
#11
|
|||
|
|||
|
While I agree with the method ghostdog74 proposes, the user specifically asked for a tcsh solution. Here is one that should work provided the files are small.
Code:
#!/bin/tcsh
set a=`awk '{print $1}' file1`
echo $a
echo "$a[2]"
echo "$#a"
set b=`awk '{print $1}' file2`
echo $b
echo "$b[2]"
echo "$#b"
if ($#a == $#b) then
echo "number of lines match"
else
echo "number of lines do not match"
endif
if ("$a" == "$b") then
echo "files match"
else
echo "files do not match"
endif
|
|
#12
|
|||
|
|||
|
Quote:
when we do line by line compare for file1 and file2 , how do I extract the value in file1 which did not match that in file2. Will it work even if sort, because there could be some order in file2. Let me know Thanks Amit Amit |
|
#13
|
|||
|
|||
|
Quote:
how do I get the line which did not match? from your script Pls help Amit |
|
#14
|
|||
|
|||
|
Quote:
then, use comm to compare them. man comm for more information |
|||
| Google The UNIX and Linux Forums |