1

I am trying to write a one-line bash script on the bash command prompt that involves input redirection:

dbs$ for $f in *; do tr '\n' '' < $f; done

but the '<' character is causing problem. Do I need to escape the < character somehow? Thanks!

0

1 Answer 1

2

It should read

dbs$ for f in *; do tr '\n' '' < $f; done

The for builtin binds the respective values that are being iterated (i.e., *) to the variable, so you cannot ask bash to expand the variable right after for.


After your Edit; The script looks fine. Your problem are being caused somewhere else.

For one thing, your invocation of tr looks wrong: You probably meant tr -d '\n'.

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.