First I would like to say thanks ahead of time to all of you, that I hope to be a part of some day. So I have a file that is a list of lines that are 5 parameters long. Such as
Bob:Wilson:Nebraska:34:yes
I need to write a program in BASH that will allow me to view the standard out put horizontally and will allow me to call the lines of text in the file like
$sh filename.sh 1
Bob
Tom
Dave
etc..
or
$sh filename.sh 1 3 4 2
Bob:Nebraska:34:Wilson
Tom:Iowa:27:Anderson
etc..
What I have written so far is
cut -d : -f$1,$2,$3,$4,$5 somefile.txt | paste -s
The problem is if the user puts in less then 5 parameters after sh filename.sh I get an error code. The user is not required to put in 5 but can call up to 5.