×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

add hex value to text file

add hex value to text file

add hex value to text file

(OP)
Hello,

I have a txt file like this text.txt :
Line1
Line2
Line3
I need to add X’03320000’ (as hex value) at the begining of each line (it represent the size of the line - in my case each line is the same size - which should make things easier).

Has anyone an idea ?

Thank you !

RE: add hex value to text file

(OP)
A few things a tried (no success) :

1.
RDW="\x03\x32\x00\x00"
LINE="t"
echo "$RDW$LINE" > result.txt
=> adds \x03\x32\x00\x00t (all ascii) in result.txt

2.
a=`cat hexfile` (or a=$(<hexfile))
sed `s/^/"${a}";/` < test.txt > result.txt
where hexfile is a file with the hex value I need (created using UltraEdit).

=> error messages : s/^/^C2: not found [No such file or directory]
: /: cannot execute [Is a directory]

3.a=`cat hexfile` (or a=$(<hexfile))
awk `{ printf ${a}";%s\n", $0 }` < test.txt > result.txt

=> error message : `{' unmatched

...evil

RE: add hex value to text file

(OP)
Thank you ... but it did not work ...
BEGIN: not found [No such file or directory]

I tried without the BEGIN, and I get the same errors as before (`{' unmatched).


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close