1

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.

1 Answer 1

1

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"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.