I have this variable:
a='/08/OPT/imaginary/N/08_i_N.out'
I want to use "/" as a field separator.
Then, I want to extract the first pattern.
I have tried:
awk -F/ '{print $1}' "$a"
But I get:
awk: cannot open /08/OPT/imaginary/N/08_i_N.out (No such file or directory)
I do not want the file, only to work on the path of that file.
>Solution :
Same way as any other command, either of these (or other alternatives, e.g. within "here-documents" or passed as awk variables or…):
printf '%s\n' "$a" | command
command <<<"$a"