Question

I have a file where the first line looks something like this:

"Window Size" "Param 1" Result Time

So it basically has some words separated by spaces. I need a Linux command that will read the word at a specific position, where words enclosed in quatation marks should be seen as one word (and returned without the quatation marks).

So if I execute the command with the number 1 (doesn't matter if it starts from 0), the following should be returned:

Window Size

If executed with 3, it should return:

Result

Any idea how to do this, with awk maybe?

Était-ce utile?

La solution

Let's say the name of your file containing your data is test.txt. One possible solution in BASH with arrays:

eval "E=( $(cat test.txt) )"
echo ${E[0]}
echo ${E[2]}

The output is:

Window Size
Result
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top