Solved

Concatenate two output in the same line

Posted on 2008-06-25
7
885 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

In this tutorial I will explain how to make squid prevent malwares in five easy steps: Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-…
Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
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…

707 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

11 Experts available now in Live!

Get 1:1 Help Now