Hi experts
I want your help to change the file format to my wanted version, please give me a hand thanks
$cat file
install pass
make os pass
make build kernel failed
usb storage pass
chane to
| *install* | *make os* | *make build kernel* | *usb storage* |
| pass | pass | failed | pass |
Try this straight fwd one:
awk '{ f=f" | "$NF; $NF="\b"; s=s" | *"$0"*";}END{ print s" |";print f" |"; }' file
---------- Post updated at 01:03 AM ---------- Previous update was at 01:01 AM ----------
Hi dannis, first, thanks for your help it works I changed my question to
file1
$cat file1
install pass
make os pass
make build kernel failed
usb storage pass
file2
$cat file2
install hung
make os pass
make build kernel failed
usb storage pass
file3
$cat file3
install hung
make os pass
make build kernel failed
usb storage hung
merge file1 file2 file2 into file4 like
| date | *install* | *make os* | *make build kernel* | *usb storage* |
| ^| pass | pass | failed | pass |
| ^| hung | pass | failed | pass |
| ^| pass | pass | failed | hung |
---------- Post updated at 02:31 AM ---------- Previous update was at 01:03 AM ----------
just re-edit my question
Something like:
awk 'BEGIN{print "| date | *install* | *make os* | *make build kernel* | *usb storage* |"}
f!=FILENAME{if(s)print s ;f=FILENAME;s="|^|" $NF "|";next}
{s=s $NF "|"}
END{print s}' file1 file2 file3
Thanks it works, a quick question here, if I dont' know how many file I will merge,(eg:file5 file6 file7 ....) how to deal with it
To process all the files with names beginning with file:
awk 'BEGIN{print "| date | *install* | *make os* | *make build kernel* | *usb storage* |"}
f!=FILENAME{if(s)print s ;f=FILENAME;s="|^|" $NF "|";next}
{s=s $NF "|"}
END{print s}' file*
my (@key,@status);
while(<DATA>){
if(/^(.*)\s+(\S+)\s*$/){
push @key, "|* $1 *|";
push @status, "|* $2 *|";
}
}
print "@key\n";
print "@status\n";
__DATA__
install pass
make os pass
make build kernel failed
usb storage pass