Ok so I asked a similar question so please forgive me.. but I think this one is different enough to warrant its own thread. I'm a bit confused about how to deal with multiple files at the command line.
Lets say file one is a list, and I want to print out every line in file 2 that matches the current element in the list file1. In a script you would do this by making a nested foreach loop and using arrays or you could do it by making a hash and then checking the hash.. How would one do this at command line (specifically dealing with 2 files ) ? Something like this where the file 2 lines only are piped in to the matching part:
perl -walne'$h{$F[0]}.="$F[1] "; END{#Line from file2 here#=~/$h{$_}/&&print"$h{$_}"for keys%h}' file1.txt file2.txt
In reply to Dealing with multiple input files at Command lLine by ZWcarp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |