2

for a script i must create a file and add a line (only numeric) to this. But this should be in binary mode, but I havent found a solution.

My actually commands:

SIZE=200
touch quota
echo $SIZE >> quota

How can do this in binary mode?

4
  • 2
    What is "binary mode" supposed to mean? Commented Aug 7, 2013 at 11:37
  • a file can be created/uploaded in ASCII OR Binary Mode Commented Aug 7, 2013 at 11:40
  • That still means bupkis given that echo is generally for text. Commented Aug 7, 2013 at 11:43
  • I guess its a duplicate : stackoverflow.com/questions/9955020/… Commented Aug 7, 2013 at 11:51

1 Answer 1

1

Perhaps you need to use the -n option?

echo -n "$SIZE" >> quota

Or maybe you need the binary representation it but this is only limited to 8 bits or 255.

echo -ne "$(printf '\\x%x' 200)" >> quota

Also make sure that you really need to use >> and not > as >> appends data to existing files, not overwrite it.

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.