How can I get mv (or the * wildcard) to move hidden files?

1

I am migrating my home directory from an old system to a new one, and the tarball I made contains everything, including hidden files like .bashrc. However, when I move the contents of the unpacked tarball (which are in /tmp) to my new home directory, the hidden files do not copy (mv /tmp/home/rcook/* /home/rcook/). How can I get mv to move them?

Actually, I think the problem is not with mv, but with bash's globbing. If I do this:

mkdir a mkdir b touch a/.foo touch a/bar mv a/* b/ ls -a a/ b/

I see this:

a/: . .. .foo b/: . .. bar

a/.foo did not move. So how can I get the * wildcard to find hidden files?

Yes, I suppose I could decompress the tarball directly into my home directory, but the tarball decompresses into home/rcook/..., and I want to be sure I overwrite the new .bashrc, etc. with the old, customized versions, and knowing how to find and move hidden files is a worthwhile skill. Suggestions?

Some answers suggest doing something like mv...

0 0
2

You can find a comprehensive set of solutions on this in UNIX & Linux's answer to How do you move all files (including hidden) from one directory to another?. It shows solutions in Bash, zsh, ksh93, standard (POSIX) sh, etc.

You can use these two commands together:

mv /path/subfolder/* /path/ # your current approach mv /path/subfolder/.* /path/ # this one for hidden files

Or all together (thanks pfnuesel):

mv /path/subfolder/{.,}* /path/

Which expands to:

mv /path/subfolder/* /path/subfolder/.* /path/

(example: echo a{.,}b expands to a.b ab)

Note this will show a couple of warnings:

mv: cannot move ‘/path/subfolder/.’ to /path/.’: Device or resource busy mv: cannot remove /path/subfolder/..’: Is a directory

Just ignore them: this happens because /path/subfolder/{.,}* also expands to /path/subfolder/. and /path/subfolder/.., which are the directory and the parent directory (See What do “.” and “..” mean when in a folder?).

If you...

0 0
3

Aha! Simple, you say. Just go to the graphical interface you’re using for your Linux system. Then you can quickly and easily move the file of your choice from one place to another, copy it, or zap it into nothingness.

Now, what if you wanted to move (or copy or delete) many files at the same time? In particular, what if you wanted to move all files with the same characters at the end of their name, like joe_expenses, cath_expenses, mike_expenses and robin_expenses?

In the case mentioned above, the Linux command line offers far greater power and efficiency than the GUI. For instance, to instantly seek out and move all of the files above to a subdirectory called budget, your command line instruction would simply be:

Each of the Linux commands to move, copy, or delete files have options to make it more productive. Read on to find out more.

1. mv: Moving (and Renaming) Files

The mv command lets you move a file from one directory location to another....

0 0
4
Okay I got it working. Here it is if anyone is interested.

################################################## ########
## Backup Script ##
## Grabs files and makes increments of them. ##
################################################## ########
#! /bin/bash

#### Setup and Config ####
##########################

## Enter the dir directory you want to backup
# /bin will backup the file bin and everything inside
# /bin/ will back up all files inside bin but not the file
srcDir="/home/chris/Desktop/files/"

## Enter the location of you backup location
# eg. /hardrive2/backups/
bakDir="/home/chris/scripts/"

## How many backups would you like to keep
# Note: The only size increase is from newly added or updated files
incNum=3

#### Logic and Commands ####
############################
curDate=`date +%d_%b_%Y`

## Remove oldest dir
echo
echo "Removing...

0 0
5

Questions:

Its must be a popular question but I could not find an answer.

How to move all files via * including hidden files as well to parent directory like this:

mv /path/subfolder/* /path/

This will move all files to parent directory like expected but will not move hidden files. How to do that?

Answers:

You can find a comprehensive set of solutions on this in UNIX & Linux’s answer to How do you move all files (including hidden) from one directory to another?. It shows solutions in Bash, zsh, ksh93, standard (POSIX) sh, etc.

You can use these two commands together:

mv /path/subfolder/* /path/ # your current approach mv /path/subfolder/.* /path/ # this one for hidden files

Or all together (thanks pfnuesel):

mv /path/subfolder/{.,}* /path/

Which expands to:

mv /path/subfolder/* /path/subfolder/.* /path/

(example: echo a{.,}b expands to a.b ab)

Note this will show a couple of warnings:

mv: cannot move...
0 0
6

Ok ..

lets try this .. I found this doc here does this help?

SYS ADM: Error when moving large group of files - arg list is too long.

Current Path Home
Score : 0
Document Type : EN
Date : 1998 Aug 16
Description : SYS ADM: Error when moving large group of files - arg list is too long.
Document Id : A5218911
Search String :

You may provide feedback on this document

View the printer friendly version of this document

--------------------------------------------------------------------------------

Problem Description

I am trying to move a group of files that are specified with
a wildcard. I am getting this error:

arg list is too long.

Why am I getting this message?

Configuration Info

Operating System - HP-UX
Version - 10.20
Hardware System - HP9000
Series - D350

Solution

The file names are about 45 characters, and you are...

0 0
7

I can move one file to the folder at a time, but I can't seem to move both

I keep getting The syntax of the command is incorrect. even if I remove the comma in between the two files.

The source must be a single file, a directory, or a wildcard expression. None of these apply in your case, where you are specifying two files.

The syntax of the move command is:

Syntax

MOVE [options] [Source] [Target]

Key

source : The path and filename of the file(s) to move. target : The path and filename to move file(s) to. options: /Y Suppress confirmation prompt, when overwriting files. /-Y Enable confirmation prompt, when overwriting files.

Both Source and Target can be either a folder or a single file.

The source can include wildcards (but not the destination).

Source move

Assuming that your source directory contains only the 2 ipynb listed in the question you can use the following command:

move *.ipynb "Scraping...
0 0
8

By using the find command in conjunction with the mv command, you can prevent the mv command from trying to move directories (e.g. .. and .) and subdirectories. Here's one option:

find /path/subfolder -maxdepth 1 -type f -name '*' -exec mv -n {} /path \;

There are problems with some of the other answers provided. For example, each of the following will try to move subdirectories from the source path:

1) mv /path/subfolder/* /path/ ; mv /path/subfolder/.* /path/ 2) mv /path/subfolder/{.,}* /path/ 3) mv /source/path/{.[!.],}* /destination/path

Also, 2) includes the . and .. files and 3) misses files like ..foobar, ...barfoo, etc.

You could use, mv /source/path/{.[!.],..?,}* /destination/path, which would include the files missed by 3), but it would still try to move subdirectories. Using the find command with the mv command as I describe above eliminates all these...

0 0
9

Filenames can be hard to handle if their names include control characters or characters that are special to the shell. Here's a directory with three oddball filenames:

% What now a$file prog|.c program.c

When you type those filenames on the command line, the shell interprets the special characters (space, dollar sign, and vertical bar) instead of including them as part of the filename. There are several ways (23.11) to handle this problem. One is with wildcards (15.2). Type a part of the filename without the weird characters and use a wildcard to match the rest. As article 8.5 explains, the shell doesn't scan the filenames for other special characters after it interprets the wildcards, so you're (usually) safe if you can get a wildcard to match. For example, here's how to rename What now to Whatnow, remove a$file, and rename prog|.c to prog.c:

% % rm: remove a$file? %

Filenames with control characters are just another version of the same problem. Use a...

0 0
10

Below are the steps required to move computer files from one source to another. Click on one of the links below to scroll down automatically to the operating system you need help with, or scroll down to review them all.

Note: When moving files you are going to have only one copy of the files you move. If you want more than one copy of the files you should copy the files and not move them.

How to move files in Windows

In Windows, you can move files in a number of ways. You can drag-and-drop, cut and paste, or use the "Move to Folder..." command. Below are the all of the steps on how you can move files in Windows, choose the option that works best for you.

Tip: You can also select multiple files and move multiple files at once using any of the steps below.

Cut and paste

To cut and paste a file, select the file you want to move, right-click on the highlighted file, and then select Cut. Browse to the folder you would like to move the file to...

0 0
11
Using the * wildcard characters with mv, cp, and rm

If you can see this check that

Using the * wildcard characters with mv, cp, and rm

Wildcard characters are often useful when you want to move or copy multiple files from one directory to another. For example, suppose you have two directories immediately below your current directory, named 'new' and 'old', and these directories contain the following files:

% ls new myfile myfile2 % ls old myfile3 myfile4

To move all the files from the directory 'new' into the directory 'old', we would type:

% mv new/* old % ls new ( no files in new) % ls old ( all files are now in old) myfile myfile2 myfile3 myfile4

We can do a similar operation with the cp command. For example, to copy all the files from old into new, we could type:

% cp old/* new

Similarly, we can use wildcard characters with the rm command. For example, to remove all of the files in the directory new, type:

% rm new/* %...
0 0