Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

preserving whitespace in variables

Status
Not open for further replies.

dendenners

Programmer
Jul 17, 2001
110
IE
Hi,
I need to extract the first line from a file, manipulate a section of the line and re-insert it into the file. The problem I'm encountering is that I don't seem to be able to preserve trailing whitespace in the line when I pass it into a variable. At the moment, I'm carving up the line like this:
echo "$header_line" | cut -c54-$header_line_length | read new_header_line_3
However, when I access $new_header_line_3, the variable is truncated and trailing whitespace has disappeared! I'm sure there is a way around this using awk or something, but I don't seem to be able to get it to work. Thank you.
 
Try ...

new_header_line_3=$("$header_line" | cut -c54-$header_line_length)

Greg.
 
Try ...

new_header_line_3=$(echo "$header_line" | cut -c54-$header_line_length)

Greg.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top