Page 1 of 1

few more shell doubts

Posted: 2018/01/20 18:04:24
by knzzz
Hi Team,

1.if i want to move mutiple files from my current folder to another folder instead of using one by one is it possible by using parathesis

mv FILE NAME /path/of/folder

2. How to go to particular line of the script in case if the condition is not satisfied

Regards
Kanna

Re: few more shell doubts

Posted: 2018/01/20 19:09:15
by desertcat
knzzz wrote:Hi Team,

1.if i want to move mutiple files from my current folder to another folder instead of using one by one is it possible by using parathesis

mv FILE NAME /path/of/folder

2. How to go to particular line of the script in case if the condition is not satisfied

Regards
Kanna
OK Call me LAZY but my favourite must have utility is called Midnight Commander (mc) which is an improved version of the old DOS Utility made famous by Norton Utilities call Norton Commander. You can set it up so you can have two "windows" open. In one you highlight the files you want to move or copy; in the other the destination directory or folder you want to move those files to. Hit F5 and presto the files are copied or moved to the destination directory or folder. If you want to delete them from the original folder you hight them again and hit F8 -- Gone!! You can also edit files, make new directories, etc., etc., etc. Unless you are wedded to the CLI, or happen to like pain, install mc [yum install mc], and you'll never look back again!!

Re: few more shell doubts

Posted: 2018/01/21 02:19:04
by kt53
$ mkdir test1 test2
$ cd test1
test1 $ touch file1 file2 file3
test1 $ ls
file1 file2 file3
test1 $
test1 $ mv file1 file2 file3 ../test2
test1 $ cd ../test2
test2 $ ls
file1 file2 file3
test2 $ mv file* ../test1
test2 $ cd ../test1
test1 $ ls
file1 file2 file3
test1 $

Re: few more shell doubts

Posted: 2018/01/21 07:36:10
by desertcat
kt53 wrote:$ mkdir test1 test2
$ cd test1
test1 $ touch file1 file2 file3
test1 $ ls
file1 file2 file3
test1 $
test1 $ mv file1 file2 file3 ../test2
test1 $ cd ../test2
test2 $ ls
file1 file2 file3
test2 $ mv file* ../test1
test2 $ cd ../test1
test1 $ ls
file1 file2 file3
test1 $
Which proves my point: you have to do all this typing, or you can use mc. It is far easier especially if you are constantly moving a lot of files, creating a lot of directories, or editing files to use mc.

Re: few more shell doubts

Posted: 2018/01/21 16:05:11
by kt53
NO. You do NOT need to do all these typing.

These were written to teach you how to use the mv command in Linux.

All you need to do is:

$ mv file1 file2 file3 /path-to-target-directory

Re: few more shell doubts

Posted: 2018/01/22 09:58:20
by pjsr2
CentOS comes with manual pages for all commands, which are accessed through the command "man". Study the output of the following command carefully:

Code: Select all

man mv