Z
Z
zooks2016-11-25 08:20:58
linux
zooks, 2016-11-25 08:20:58

How to use result of ls command in mv command?

I'm looking for a way not to use the mouse when renaming files.
This is usually done like this:

ls *.txt
mv somelongfilename.txt shortname.txt

In this case, the file name must be copied, highlighting the output of ls with the mouse.
PS I am aware of the existence of the Tab key. It would be desirable to combine mv and ls in one command.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Rsa97, 2016-11-25
@zooks

The file name does not have to be copied at all, it can simply be typed from the keyboard.
And for mass renaming in Linux there is a rename command .
If there is only one file:
mv `ls -1 old_mask` new_name

S
Stanislav Gorovoy, 2016-11-25
@Cnfc19932

why do you need ls at all? Write a small bash script and that's it

P
pomeo, 2016-11-25
@pomeo

for i in `ls`;do mv $i 123${i}; done
will add 123 to all files in the directory in the name

A
Andrey Mikhalev, 2016-11-25
@Endru9

I don’t know how much easier this option is, but 100% convenient https://github.com/mooz/percol

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question