Copying files with caps?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Copying files with caps?
# 1  
Old 02-19-2011
Copying files with caps?

Anyone know the proper command to copy files whose names CONTAIN a capital letter to a diff location? Every time I do it I ke copying ALL the files. Here is what ive tried

Code:
cp *[A-Z]* newlocation
 
cp [A-Z] newlocation

# 2  
Old 02-19-2011
Shell globbing doesn't work like that, * means "match anything" not "match multiples of the previous char". So I don't think shell globbing can do it.

I think you could do it with grep by matching anything that's NOT what you want and reversing it with -v. So:

Code:
ls | grep -v "[^A-Z]" | while read FILE ; do [ ! -d "$FILE" ] && cp "$FILE" /new/location/


Last edited by Corona688; 02-19-2011 at 12:40 PM.. Reason: Exclude directories
# 3  
Old 02-19-2011
Seems rather legthy just to copy files from one directory to another though. I swear Ive seen this done before. I will keep scouring the web and post a reply when I finally find it. Itd be nice to know so if you signify file names with a capital letter in them because they are part of a structure you are constantly moving or backing up youd be able to do so easilly.

Last edited by losingit; 02-19-2011 at 12:52 PM.. Reason: grammar
# 4  
Old 02-19-2011
Quote:
Originally Posted by losingit
Itd be nice to know so if you signify file names with a capital letter in them because they are part of a structure you are constantly moving or backing up youd be able to do so easilly.
Oh, just ONE capital letter?

Code:
cp *[A-Z]* newlocation

should work fine. If it doesn't, please post what it actually did, including error output even if it didn't actually succeed in copying anything.
# 5  
Old 02-19-2011
Ive tried that and I thought that would be it but it also copies files without capital letters. Im looking to copy any file that contains any amount of capital letters. So if I had files named

Zebra
uPPer
down
side
horsE

I would copy Zebra, uPPer and horsE
# 6  
Old 02-20-2011
Corona688's cp command should work.

Another one:
Code:
ls *[A-Z]* |xargs -i cp {} newlocation

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copying files

I'm trying to do this exact same thing, so far I have created this to move files i've named my script CP.sh #!/bin/bash cd /root/my-documents/NewDir/ for f in *.doc do cp -v $f root/my-documents/NewDir $f{%.doc} done When i go to run this in the console i type, bin/sh/ CP.sh but it... (7 Replies)
Discussion started by: MKTM_93_SIMP
7 Replies

2. Shell Programming and Scripting

Copying files

All, I need to grab and rename common files from several unique directory structures. For example, the directory structures looks like: /unique_dir/common/common/common/person_name_dir/common_file.txt There are over 90,000 of these text files that I'd like to put in a single directory as... (5 Replies)
Discussion started by: hburnswell
5 Replies

3. Shell Programming and Scripting

Generate all possible word with caps and no caps

With use of sed/awk, how can I print all possible combinations of a word with caps/non-caps. Eg Applying operation on "cap" should generate output as follows. cap CAP Cap cAp caP CAp cAP CaP (12 Replies)
Discussion started by: anil510
12 Replies

4. Shell Programming and Scripting

Commands in all caps

Is it possible to make a bash script such that entering a command in all capital letters would be equivalent to using "sudo" before that command? For example: "sudo chmod 777 foo.txt" becomes "CHMOD 777 foo.txt" (3 Replies)
Discussion started by: bloom
3 Replies

5. Shell Programming and Scripting

Files copying - [ Listed files alone. ] - Shell script

Hi All, I am doing this for svn patch making. I got the list of files to make the patch. I have the list in a file with path of all the files. To Do From Directory : /myproject/MainDir To Directory : /myproject/data List of files need to copy is in the file: /myproject/filesList.txt ... (4 Replies)
Discussion started by: linuxadmin
4 Replies

6. Shell Programming and Scripting

Copying Files

Hi All, I'm trying to list some files from my log directory and files are like this log.20110302_20.gz log.20110302_21.gz log.20110302_22.gz log.20110302_23.gz log.20110303_00.gz log.20110303_01.gz log.20110303_02.gz ............ log.20110311_22.gz log.20110311_23.gz... (2 Replies)
Discussion started by: thelakbe
2 Replies

7. UNIX for Advanced & Expert Users

copying of files by userB, dir & files owned by userA

I am userB and have a dir /temp1 This dir is owned by me. How do I recursively copy files from another users's dir userA? I need to preserve the original user who created files, original group information, original create date, mod date etc. I tried cp -pr /home/userA/* . ... (2 Replies)
Discussion started by: Hangman2
2 Replies

8. Shell Programming and Scripting

copying files

hi I want to copy all files from the current directory and move to .archive file. Moreover,I want to add .bak to each file name, that will be copied. How can I do that? (4 Replies)
Discussion started by: tjay83
4 Replies

9. Solaris

Copying Files and

I am new user to solaris and installed solaris operating system on full Harddisk 120Gb. I am unable to copy music files to desktop and /home directory. One thing happened while registering is- i entered login-root and its password. The message prompted your system is crashed. Is it because of... (1 Reply)
Discussion started by: patilmukundraj
1 Replies

10. UNIX for Dummies Questions & Answers

Copying files

I like to know the command structure of copying files/directories from a unix box using telnet session to a windows box. (4 Replies)
Discussion started by: alpheusm
4 Replies
Login or Register to Ask a Question