Solved

Concatenate two output in the same line

Posted on 2008-06-25
7
894 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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 

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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

705 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