cbillson
July 31st, 2013, 02:12 PM
lets say i have a file that has:
name=123 data=blah
name=124 data=blah
name=125 data=blah
name=126 data=blah
name=127 data=blah
i need to get "123" into a variable, so i could use a for loop and grep (cat myfile | grep "name=", but is there any way i can grep or only select the data up to the next space?
Also, when using arrays, if you split a line of data up into data[1] data[2] etc, and you have lets say up to data[30] is there any way to easily echo data[20] to data[30] without the obvious specifying every element - kind of like data[20]+
Cheers
Chris
name=123 data=blah
name=124 data=blah
name=125 data=blah
name=126 data=blah
name=127 data=blah
i need to get "123" into a variable, so i could use a for loop and grep (cat myfile | grep "name=", but is there any way i can grep or only select the data up to the next space?
Also, when using arrays, if you split a line of data up into data[1] data[2] etc, and you have lets say up to data[30] is there any way to easily echo data[20] to data[30] without the obvious specifying every element - kind of like data[20]+
Cheers
Chris