So i am wring a script that would take several files, compare them and then output the different records.
The script is working fine for 3 parameter ( 3 files ), but i am having trouble to make the parameters vary.
Consider the script is named Test.
If i write: Test 1.txt 2.txt,
The script will know that i have 2 inputs, which are 2 files and will compare them and give me an output.
Furthermore, if i write Test 1.txt 2.txt 3.txt,
The script will know that i have 3 inputs, which are 3 files, compare them and give me an output.
The script now has the following commands :
awk 'NR>2' ${1} | awk '{print $NF "\r"}' > N1
awk 'NR>2' ${2} | awk '{print $NF "\r"}' > N2
awk 'NR>2' ${3} | awk '{print $NF "\r"}' > N3
This is working fine for 3 files, but the problem is that sometimes i have 2 files, sometimes i have 4 files.
I know i can fix that using loops, but i am new to this language and not very familiar with the syntax.
Thank you for your help :)