Solved

Concatenate two output in the same line

Posted on 2008-06-25
7
892 Views
Last Modified: 2010-05-18
Hi,  I'd know how  concatenate two output in the same line. And then save to file.
 eg:
$:  ls  || pwd > file.txt
0
Comment
Question by:mauriff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 14

Expert Comment

by:agriesser
ID: 21865441
(ls || pwd) >file.txt

0
 

Author Comment

by:mauriff
ID: 21865753
mm.. I want make an file with string concatenate.Eg.
I run "rm -f " locate blabla.bin > rm.txt
and i want the output should be:

rm - rf /etv/bin/blabla.bin
rm - rf /home/audyt/blabla.bin
rm - rf /home/lib/blabla.bin

Is clear?
0
 
LVL 14

Accepted Solution

by:
agriesser earned 125 total points
ID: 21865874
No, it's not clear. I'm having a hard time in understanding you, but I try to answer the question in three manners.

First variant: You want to have a file that contains the commands "rm -rf *blabla.bin* listed in it", you can do that using code snippet part 1.

Second variant: Like variant #1, but the output is printed to the console instead of into a file.

Third variant: You want to execute rm -rf *blabla.bin* immediately, but with all the files matching your search query all over the filesystem.


# variant #1
for file in $(locate blabla.bin); do echo "rm -rf $file"; done
 
# variant #2
for file in $(locate blabla.bin); do echo "rm -rf $file" >>/path/to/output-file.txt; done
 
# variant #3
# !!!!! very dangerous if the you make a typo in the keyword to use !!!!!
# !!!!! could delete all the data on your disk without further interaction !!!!!
locate blabla.bin | xargs rm -rf

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mauriff
ID: 21865950
Thanks! It's just I want run!!

(Sorry for my english, I'm basic level  in this language)
0
 
LVL 14

Expert Comment

by:agriesser
ID: 21866111
So you took what variant? #3 I guess, right?
0
 

Author Comment

by:mauriff
ID: 21866156
yes!
0
 
LVL 14

Expert Comment

by:agriesser
ID: 21866185
OK, but _PLEASE_ be careful using this command. If you mistype the search string for the locate command you can easily erase data on your hard disk.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question