LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-30-2004, 03:12 PM   #1
monohouse
Member
 
Registered: Oct 2004
Distribution: Arch
Posts: 206

Rep: Reputation: 30
cat without new line


I have a problem, I want to cat something but I don't want that after every parameter I get a new line, particularly I need that the output of :
Code:
cat /proc/sys/dev/sensors/asb100-i2c-0-2d/in0 /proc/sys/dev/sensors/asb100-i2c-0-2d/in1 /proc/sys/dev/sensors/asb100-i2c-0-2d/in2 /proc/sys/dev/sensors/asb100-i2c-0-2d/in3 /proc/sys/dev/sensors/asb100-i2c-0-2d/in4 /proc/sys/dev/sensors/asb100-i2c-0-2d/in5 /proc/sys/dev/sensors/asb100-i2c-0-2d/in6
will not be :
Code:
1.39 2.08 1.81
1.39 2.08 1.81
2.96 3.63 3.28
2.67 3.28 3.02
2.51 3.79 3.28
0.00 0.00 3.28
0.00 0.00 3.28
but instead :
Code:
1.39 2.08 1.81 1.39 2.08 1.81 2.96 3.63 3.28 2.67 3.28 3.02 2.51 3.79 3.28 0.00 0.00 3.28 0.00 0.00 3.28
anyone would know how to accomplish this ?
 
Old 10-30-2004, 03:15 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Code:
cat file file file | tr '\n' ' '
 
Old 10-30-2004, 04:21 PM   #3
monohouse
Member
 
Registered: Oct 2004
Distribution: Arch
Posts: 206

Original Poster
Rep: Reputation: 30
thanks !

I may have another question though..........

what if I want to remove a certain string from the pipe ?
 
Old 10-30-2004, 04:29 PM   #4
itzfritz
Member
 
Registered: Oct 2004
Location: Babylon, New York
Distribution: debian lenny, ubuntu intrepid
Posts: 70

Rep: Reputation: 15
that would be
Code:
cat <whatever> | tr -d '<string to delete>'

note that
Code:
cat <whatever> | tr '\n' ' '
will replace newlines with space character.
 
Old 10-30-2004, 04:45 PM   #5
monohouse
Member
 
Registered: Oct 2004
Distribution: Arch
Posts: 206

Original Poster
Rep: Reputation: 30
thanks dude !, yet it's still not exactly as I want it to be though ......

it seems that -d takes whatever in ' ' as independent chars, I need it to be a real string.
 
Old 10-30-2004, 04:54 PM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
to delete words, you need sed, not tr. they are different tools, and do their own function very well. see the sed manpage for details, but essentially... "cat blah | grep s/la/ooo/g" will give "boooh"
 
Old 10-30-2004, 05:09 PM   #7
monohouse
Member
 
Registered: Oct 2004
Distribution: Arch
Posts: 206

Original Poster
Rep: Reputation: 30
though grep gave me an error, I quickly (after reading the manual for sed) figured that you actually mean sed.

thanks dudes, you've been VERY helpful !

also I found a strange thing ...........if you give cat more than 4 files and then pipe them through
Code:
| tr '\n' ' '
the
Code:
tr '\n' ' '
part doesn't work, maybe it has a limit on the number of operations

Last edited by monohouse; 10-30-2004 at 05:11 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ text file line by line/each line to string/array Dimitris Programming 15 03-11-2008 08:22 AM
My Cat unimaginative General 71 02-18-2004 01:08 PM
Cat ... Beuzekom Linux - Newbie 4 01-19-2004 05:32 PM
linux scripting help needed read from file line by line exc commands each line read atokad Programming 4 12-26-2003 10:24 PM
regarding cat gui10 Linux - Security 6 12-07-2001 08:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration