Help appending text to file, using variables
I know how to append text to a file, but I need it appended to the same line as the original text and there are variables involved.
Code:
#!/bin/bash I've seen some tutorials using 'sed', but the text to be appended is always in single quotes, which will not allow expansion of the variables. |
echo is the command, not cat
your cat of a directory is fallacious... it shouldn't success...
cat just concats files. And the newline appended can be suprimed with the -n flag so echo -n hi >> msg echo -n " dude" >> msg cat msg [hi dude] |
Quote:
Here's how I have it written.. Code:
echo -n " $dir".img >> filename".md5" Code:
09874508909870987985234... /path/to/directory.img Code:
09874508909870987985234... |
Until you use shell redirection the new piece of text will be appended to a new line. You need a editor, instead. And what's better than sed? :)
Code:
sed -i "s:$: $dir:" $file |
deleted
|
the newline was already there
Quote:
You have to "sanitize" the md5 file (or any file): a simple solution would be to take the whole file but the last line. Write those lines as they are and the append the last line without newline character. Code:
# copy file from $1 to $2, removing the ending newline, if any Code:
takeoffnewline mysum.md5 mysum2.md5 |
All times are GMT -5. The time now is 11:04 PM. |