Solved

Concatenate two output in the same line

Posted on 2008-06-25
7
887 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
  • 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
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,…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

895 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now