I am having a requirement where I need to extract couple of fields from a file with last field. structure of file can be different so cannot hardcode the last field. lets take example of two different files
File1
a,b,c
d,e,f
another file File2
a,a,a,a
b,b,b,b
requirement can be like extract 1st and last field from file1 or requirement can be like extract 2nd and last field from file2
We get this requirement from a configuration table where they mention which field they want to extract but last field is common. one way is to use while loop but with out while loop is there any way that we can achieve this?
printf '%s\n' a,b d,e,f
has 2 fields in line #1, and 3 fields in line #2.) – agc May 22 '19 at 11:51