Bhavya Arora Bhavya Arora - 4 months ago 16
Bash Question

Output of cut, value: command not found

I have a script
.

...
join -1 3 -2 3 $fileName1 $fileName2 > temp.txt
($(cut -d' ' -f1 temp.txt))
.
.


I expect the output to be

c


but I get

c: command not found


I am really new to bash scripting, any help would be appreciated :)

Answer

Just write:

cut -d' ' -f1 temp.text

When you put a command in $(), it substitutes the output back into the command line. And then, since this is at the beginning of the command line, it tries to execute the output as if it's another shell command.