You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[rsync Q&A on unix stackexchange](https://unix.stackexchange.com/questions/tagged/rsync?sort=votes&pageSize=15)
526
+
*[rsync Q&A on stackoverflow](https://stackoverflow.com/questions/tagged/rsync?sort=votes&pageSize=15)
457
527
458
528
<br>
459
529
460
530
## <aname="mv"></a>mv
461
531
462
532
>move (rename) files
463
533
464
-
The destination path is always specified as the last argument. More than one source file/folder can be specified if destination is a directory
534
+
* as name suggests, `mv` can move files from one location to another
535
+
* if multiple files need to be moved, destination argument should be a directory (or specified using `-t` option)
536
+
* unlike `rm` and `cp`, both files and directories have same syntax, no additional option required
537
+
* use `-i` option to be prompted instead of overwriting file of same name in destination location
465
538
466
-
**Options**
539
+
```bash
540
+
$ ls
541
+
bkp_dot_files dict low power adders word_lists words words_ref.txt
542
+
$ mkdir backups
467
543
468
-
*`-f` don't prompt for overwriting and moving write protected files (provided user has appropriate permissions)
469
-
*`-i` prompt before overwriting
544
+
$ mv bkp_dot_files/ backups/
545
+
$ ls -F
546
+
backups/ dict/ low power adders/ word_lists/ words words_ref.txt
547
+
$ ls -F backups/
548
+
bkp_dot_files/
470
549
471
-
**Examples**
550
+
$ mv dict words backups/
551
+
$ ls -F
552
+
backups/ low power adders/ word_lists/ words_ref.txt
553
+
$ ls -F backups/
554
+
bkp_dot_files/ dict/ words
555
+
```
556
+
557
+
* like `cp` command, for single file/directory one can provide a different destination name
558
+
559
+
```bash
560
+
$ mv backups/bkp_dot_files backups/dot_files
561
+
$ ls -F backups/
562
+
dict/ dot_files/ words
563
+
```
564
+
565
+
**Further Reading**
472
566
473
-
*`mv project_adder project_lowpower_adder` rename file or folder
474
-
*`mv power.log timing.log area.log project_multiplier/result/` move the specified files to result directory
475
567
*[mv Q&A on unix stackexchange](https://unix.stackexchange.com/questions/tagged/mv?sort=votes&pageSize=15)
476
568
*[mv Q&A on stackoverflow](https://stackoverflow.com/questions/tagged/mv?sort=votes&pageSize=15)
477
569
@@ -481,19 +573,26 @@ The destination path is always specified as the last argument. More than one sou
481
573
482
574
>renames multiple files
483
575
484
-
Note: The `perl` based `rename` is presented here and different from [util-linux-ng version](https://linux.die.net/man/1/rename). Check `man rename` for details
576
+
Note: The `perl` based `rename` is presented here which is different from [util-linux-ng version](https://linux.die.net/man/1/rename). Check `man rename` for details
485
577
486
-
**Options**
487
-
488
-
*`-f` overwrite existing files
489
-
*`-n` dry run without actually renaming files
578
+
```bash
579
+
$ ls
580
+
backups low power adders word_lists words_ref.txt
581
+
$ # here, the * glob will expand to all non-hidden files in current directory
582
+
$ # -n option is for dry run, to see changes before actually renaming files
583
+
$ # s/ /_/g means replace all space characters with _ character
584
+
$ rename -n 's/ /_/g'*
585
+
rename(low power adders, low_power_adders)
586
+
587
+
$ rename 's/ /_/g'*
588
+
$ ls
589
+
backups low_power_adders word_lists words_ref.txt
590
+
```
490
591
491
-
**Examples**
592
+
**Further Reading**
492
593
493
-
*`rename 's/\.JPG$/.jpg/' *JPG` change the file extension from '.JPG' to '.jpg'
494
-
*`rename 's/ /_/g' *` replace all 'space' characters in filenames with '_'
495
594
*[rename Q&A on unix stackexchange](https://unix.stackexchange.com/questions/tagged/rename?sort=votes&pageSize=15)
496
-
* See [Perl one liners](https://github.com/learnbyexample/Command-line-text-processing/blob/master/perl_the_swiss_knife.md) for examples and details on Perl based substitution command
595
+
* See [Perl one liners](https://github.com/learnbyexample/Command-line-text-processing/blob/master/perl_the_swiss_knife.md) for examples and details on Perl substitution command
0 commit comments