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
Solved

Concatenate two output in the same line

Posted on 2008-06-25
7
889 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Centos 7 User to Start Apache, MariaDB, LDAP 5 48
Setting up static IP - Ubuntu server 16.04 12 95
Linux VM 6 101
CLI command keep running after close 7 36
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

860 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