Once I have the output of a command, can I use that output without typing it in or resorting to complicated find/sed gibberish? Surely this is a common enough position to be in that Bash would have a facility for it built in?
For instance:
Now I know that I want to copy the third result to my $HOME folder. How can I do that simply, without chaining a bunch of tools together or typing it in from the beginning?
Thanks, Zaxxon. I had foud examples of this while googling, however, I wanted to know if there is a simple way of doing this, without chaining together three tools as in your example.
Any file manager lets the user select a file displayed and move it easily and intuitively. Would that also not be the case with bash? I know that bash is not a file manager, but it is a well-developed, popular tool that is often used for managing files.
What seems complex/awkward can also been seen from a point of view that you have far many more options of doing things with files etc. than in a file manager. Options that are in a file manager are just a little bit you can do in a shell. Especially you can do automation, write scripts and so on which you can't do with a file manager.
If you like a file manager etc. you might want to use some graphical desktop like Gnome or KDE. They bring filemanagers with them.
Also I did not use a file manager on any OS yet, that I could say, that it should take the 3rd file in the list and copy it somewhere. I always had to manually move the mouse cursor and click and drag some options.
Actually, I do use KDE. In Dolphin (and Konqueror before that) the user could easily move the selection to the third file via the arrow keys, Ctrl-C, F6 to the addressbar, type in the path (with tab-completion), then Ctrl-V to the right place.
But the question is not only of file managers, that was only an example. Another example might be looking for a package to install:
Now I know that I want to install the second and fifth packages. Must I manually type in "sudo apt-get install libqt4-ruby libqt4-ruby1.8-examples"? Why can't there be a simple "sudo apt-get install ^2 ^5"? Should I file a feature request at bash? Is this not something that would be useful to many people?
Actually, I do use KDE. In Dolphin (and Konqueror before that) the user could easily move the selection to the third file via the arrow keys, Ctrl-C, F6 to the addressbar, type in the path (with tab-completion), then Ctrl-V to the right place.
But the question is not only of file managers, that was only an example. Another example might be looking for a package to install:
Now I know that I want to install the second and fifth packages. Must I manually type in "sudo apt-get install libqt4-ruby libqt4-ruby1.8-examples"? Why can't there be a simple "sudo apt-get install ^2 ^5"? Should I file a feature request at bash? Is this not something that would be useful to many people?
The problem is that the shell isn't even looking at the output of your first command. The shell's fd for stdout is simply being copied into the subprocess that is running find/aptitude/etc. and that is outputing directly to your console.
You could write a short script or alias to select lines that you want so that "aptitude search qt | grep ruby | scriptA 2 5" would pull out those two lines and put them in a hidden file that can be found by a second script. Then "scriptB sudo apt-get install" would run the install on every line of the file.
#cat data.txt
file1 folder1
file2 thisforfile2
file3 thisfolderforfile3
lata4 folder4
step 1: create the folder first in column 2
for i in `awk '{print $2}' data.txt`
do
mkdir /home/data/$i
done
step 2: locate the files in column1 and stored them into a file
for i in... (17 Replies)
my os details as follow
bash-3.2$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.8 (Tikanga)
I run the following and encounter the following error
bash-3.2$ mysqlhotcopy -?
Can't locate DBI.pm in @INC (@INC contains:... (5 Replies)
Hi,
I have a folder with multiple (< 33) .log files.
And I have to copy the lines between two patterns from all the .log files to a new file.
(script file with a loop?)
Thanks in advance.
1.log
...
..
xx1> begin
...
..
..
>>> Total: 2 Alarms
..
.. (17 Replies)
Hello, i am trying to make an ssh connection from one server to another and invoke a script on another server.
while doing this i want to do a passwordless ssh connection for the same, for which i have used the following command
ssh-keygen -t rsa
ssh-copy-id -i... (3 Replies)
I m new to the linux environment.Help me with ur suggestions.
How can i obtain the file names alone from ls -ltr output??
And those files should have been created before three months and earlier than that..
Thanks and wishes,
Rupaa. (8 Replies)
Hi,
I am aware of the command locate/slocate. But when I try to search the file which is located in /tmp. Its not able to get it. I tried by updating the database also with the command updatedb.
Is there any consern that the command 'locate' dont check /tmp???
And I knew that locate is the... (5 Replies)
Hi All,
Please advise me how to make a copy of file from a list and store in one particular location?
For example , I have aaa.txt which contains as below, But, those *usg files might be randomly store in different location....
> cat aaa.txt
adc.usg
dfdjkf.usg
ugjfk.usg
And I want... (3 Replies)
hello all
im trying to use in sun Solaris the information received from the top command
now i several machines that dont have install the top program so when im running the script im geting error
saying after im running this code :
set MemoryInfo = `top | grep Memory`
if (... (2 Replies)
Does Solaris 10 have an equivalent to FreeBSD's `locate'?
If not, what is the best way to search for files (allowing regexp) throughout the system? (5 Replies)