Concatenate two output in the same line

Hi,  I'd know how  concatenate two output in the same line. And then save to file.
 eg:
$:  ls  || pwd > file.txt
mauriffAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
agriesserConnect With a Mentor Commented:
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
 
agriesserCommented:
(ls || pwd) >file.txt

0
 
mauriffAuthor Commented:
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
mauriffAuthor Commented:
Thanks! It's just I want run!!

(Sorry for my english, I'm basic level  in this language)
0
 
agriesserCommented:
So you took what variant? #3 I guess, right?
0
 
mauriffAuthor Commented:
yes!
0
 
agriesserCommented:
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
All Courses

From novice to tech pro — start learning today.