Search Results

Search: Posts Made By: julearn
2,638
Posted By Don Cragun
The first part: { read A; read B; printf "%s\n"...
The first part:
{ read A; read B; printf "%s\n" "$A" "$B"; sort; } < file
reads the first line from file into the shell variable A (read A) and the second line from file into the shell variable B...
2,638
Posted By MadeInGermany
Store the entire line, $0, in the array. Because...
Store the entire line, $0, in the array. Because the key $1 is part of the $0, one does not need to print it at the END.
awk '!($1 in A) || $2=="add" {A[$1]=$0} END{for(i in A) print A[i]}' file
2,638
Posted By Scrutinizer
Hi, try: awk '!($1 in A) || $2=="add"...
Hi, try:
awk '!($1 in A) || $2=="add" {A[$1]=$2} END{for(i in A) print i, A[i]}' file

or if
user role
----- ----

is part of the file:
awk 'FNR<3{print; next} !($1 in A) || $2=="add"...
Showing results 1 to 3 of 3

 
All times are GMT -4. The time now is 02:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy