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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
10-30-2004, 03:12 PM
|
#1
|
Member
Registered: Oct 2004
Distribution: Arch
Posts: 206
Rep:
|
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 ?
|
|
|
10-30-2004, 03:15 PM
|
#2
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
Code:
cat file file file | tr '\n' ' '
|
|
|
10-30-2004, 04:21 PM
|
#3
|
Member
Registered: Oct 2004
Distribution: Arch
Posts: 206
Original Poster
Rep:
|
thanks !
I may have another question though..........
what if I want to remove a certain string from the pipe ?
|
|
|
10-30-2004, 04:29 PM
|
#4
|
Member
Registered: Oct 2004
Location: Babylon, New York
Distribution: debian lenny, ubuntu intrepid
Posts: 70
Rep:
|
that would be
Code:
cat <whatever> | tr -d '<string to delete>'
note that
Code:
cat <whatever> | tr '\n' ' '
will replace newlines with space character.
|
|
|
10-30-2004, 04:45 PM
|
#5
|
Member
Registered: Oct 2004
Distribution: Arch
Posts: 206
Original Poster
Rep:
|
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.
|
|
|
10-30-2004, 04:54 PM
|
#6
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
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"
|
|
|
10-30-2004, 05:09 PM
|
#7
|
Member
Registered: Oct 2004
Distribution: Arch
Posts: 206
Original Poster
Rep:
|
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 the 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.
|
|
|
All times are GMT -5. The time now is 10:51 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|