Domanda

I have a script with the following line in it:

cut -d" " -f$operation

$operation should be variable, so that it can be for example 1,6 so that cut extracts the first and sixth word of a string, or 2-5 extracting the second until the fifth word. However, this way this does not work out, I guess bash interprets the variable as one string. How can I write this correctly?

Edit

I am very sorry, this question is meaningless. I missed another error, that made the whole thing impossible to work. Thanks to everybody wanting to help.

È stato utile?

Soluzione

for me it works in bash on Linux but you can try

cut -d" " -f"$operation"

to avoid parameter expansion. Are not there spaces?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top