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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing newline in text file

Status
Not open for further replies.

swingkyd

Programmer
Jul 10, 2003
34
CA
Pardon my lack of knowledge here. I'm having trouble getting this BASH code to NOT output a newline

Code:
cat "$datafile" | fgrep -A 4 "$STEP_STRING"|grep "$STEP_FILTER" | cut -c 49-56 |tee -a "$OUTPUT_FILE"

I don't want the output to include a newline character. I think the culprit is the program "cut" which automatically adds a newline to the output.

The other option is right after this command to go back into the file and remove the newline. Either way, I don't want a newline at the end of the cut text that gets piped to tee.

I am aware that I can just stream the output to the $OUTPUT_FILE" (which doesn't help any) but I prefer to use tee at this moment.

Anyway, can someone please help me? I don't know how to do either of the solutions.

Thanks in advance
 
Replace this:
grep "$STEP_FILTER" | cut -c 49-56
By this:
awk "/$STEP_FILTER/"'{printf substr($0,49,8)}'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top