Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pears are fruits
- apple is fruit
- carrot is veg
- celery is vegetable
- oranges are fruits
- fruits apple mycode is #q123c# for apple
- fruits pears my code is #q432c# for juicy
- veg celery my code value is #q989c# for vegetables
- veg spinach code is #q783c# and is a type of vegetable
- fruits papaya i have code #q346c#
- vegie lettuce code #q445c# is vege
- Q432C pears fruits
- Q123C apple fruit
- Q---C carrot veg
- Q989C celery vegetable
- Q---C oranges fruits
- awk 'NR==FNR { a[$1]=1; next } ($2 in a) {print $0} ' File1 File2 | sed -e 's/.*#(.*)#.*/1/' | tr [a-z] [A-Z] > outputFile
- awk 'NR == FNR{
- match($0, /#q[0-9]{3}c#/);
- fruits[$2] = substr($0, RSTART+1, RLENGTH-2);
- next
- }
- { print ($1 in fruits? toupper(fruits[$1]) : "Q---C"), $1, $3 }' file2 file1
- Q432C pears fruits
- Q123C apple fruit
- Q---C carrot veg
- Q989C celery vegetable
- Q---C oranges fruits
Add Comment
Please, Sign In to add comment