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

Removing newline characters from awk output

Status
Not open for further replies.

HDSJimmy

Programmer
Oct 26, 2010
1
US
I'm trying to parse a text file that has a bunch of numbers all on new lines, example:

66124
66125
66587
65874

I'm pulling in those numbers line by line and using them to pull data from another text file that has detailed information I need to capture. My bash script pulls the information between the truck number and a constant then puts that information in a text file called truck$line.txt, but it keeps adding the newline to the filename, example:

truck66124.txt (how I want it)

truck66124
.txt (how I get it currently)

Here's the awk command I'm using:

while read line
do

awk "/$line/,/TIME/" ImportData.text > truck$line.txt
done <trucks.txt

How can I remove the newline characters?

Thanks a bunch
 
Are you sure that your data file is OK? It looks like you might have an extra Carriage Return at the end of the line. Did you move the file over from Windows and not perform the dos2unix?
 
Ugh, why didn't I think of that? Guess I'm not used to dealing with Windows. That fixed it, thanks a bunch.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top