move a set of files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers move a set of files
# 1  
Old 04-24-2009
Question move a set of files

Hi Everyone!!!

Is there any command to move/copy set of files in a specific range.

Eg :
I have 800 text files in a directory
A1 ... A800

I would like to copy only files in range A40 ... A250.
I can acheive this using a "for" loop , but I guess there could be some command or Identifier ( with sed/grep/cp) which I can use to do this.
Can somebody help !!!

Regards
JR
# 2  
Old 04-24-2009
how about:
Code:
for file in `perl -e 'for $n (40 .. 250) { print "A$n", "\n"; }'`; do echo moving file $file ... ; mv $file /somewhere/else/ ; done

# 3  
Old 04-24-2009
Quote:
Originally Posted by joey_reddy
Hi Everyone!!!

Is there any command to move/copy set of files in a specific range.

Eg :
I have 800 text files in a directory
A1 ... A800

I would like to copy only files in range A40 ... A250.
[...]
Which shell you are using (exact version if possible)?
# 4  
Old 04-27-2009
I Use ksh , I am able to acheive the desired output using a simple for loop.

for (( i = 40; i <= 250; i++ )) ; do ; cp A$i /var/tmp ; done

However my Mind wants some command (like sed..) to give the output. Im sure there could be some command which can replace the above for loop.

Thanks to all the gurus who responded !!
# 5  
Old 04-27-2009
It seems you're using ksh93, so you may use brace expansion:

Code:
cp A{40..250} /var/tmp

# 6  
Old 04-29-2009
Thanks .. The cp command works very well for bash, but is not working on ksh .. Smilie

Can you please help me with a ksh version of the command.
# 7  
Old 04-29-2009
What version of the Korn shell you are using?
You said you use a loop like this (which implies ksh93):

Code:
for (( i = 40; i <= 250; i++ )) ...



but the brace expansion doesn't appear to work (ksh88, pdksh or other variant) ...

If you have the old ksh88 and you don't want to use external tools, you will need something like this:

Code:
cp A@([4-9][0-9]|[12]@(50|[0-4][0-9]))  /var/tmp

 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Move files with a certain suffix based on how many files are in another folder

Hello, First time poster. I am looking for a way to script or program the process of moving files from one folder to another, automatically, based on the count of files in the destination folder. I was thinking a shell script would work, but am open to the suggestions of the experts... (6 Replies)
Discussion started by: comtech
6 Replies

2. Shell Programming and Scripting

SBATCH trinity for multiple files and rename/move the output files

Hey guys, I have wrote the following script to apply a module named "trinity" on my files. (it takes two input files and spit a trinity.fasta as output) #!/bin/bash -l #SBATCH -p node #SBATCH -A <projectID> #SBATCH -n 16 #SBATCH -t 7-00:00:00 #SBATCH --mem=128GB #SBATCH --mail-type=ALL... (1 Reply)
Discussion started by: @man
1 Replies

3. Shell Programming and Scripting

Help needed with shell script to search and replace a set of strings among the set of files

Hi, I am looking for a shell script which serves the below purpose. Please find below the algorithm for the same and any help on this would be highly appreciated. 1)set of strings need to be replaced among set of files(directory may contain different types of files) 2)It should search for... (10 Replies)
Discussion started by: Amulya
10 Replies

4. Shell Programming and Scripting

Move all files except sys date (today) files in Solaris 10

I want to move all files from one directory to another directory excluding today (sysdate files) on daily basis. file name is in pattern file_2013031801, file_2013031802 etc (2 Replies)
Discussion started by: khattak
2 Replies

5. Shell Programming and Scripting

move set of files to the target path with different extension

I have the following files in the dir /home/krishna/datatemp abc.xml cde.xml asfd.txt asdf_20120101-1.xml asdf_20120101-2.xml asdf_20120101-3.xml asdf_20120101-4.xml Now I need to move the files having the pattern asdf_20120101-*.xml to the dir /home/krishna/dataout with the extn as... (1 Reply)
Discussion started by: kmanivan82
1 Replies

6. Shell Programming and Scripting

search for a set of characters and move

I want to search/grep for a set of characters in a file(all occurences) and move them to another file. Any command line? regards, Sri (2 Replies)
Discussion started by: Sriranga
2 Replies

7. Shell Programming and Scripting

Finding compound words from a set of files from another set of files

Hi All, I am completely stuck here. I have a set of files (with names A.txt, B.txt until L.txt) which contain words like these: computer random access memory computer networking mouse terminal windows All the files from A.txt to L.txt have the same format i.e. complete words in... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

8. Shell Programming and Scripting

Recursively move directories along with files/specific files

I would like to transfer all files ending with .log from /tmp and to /tmp/archive (using find ) The directory structure looks like :- /tmp a.log b.log c.log /abcd d.log e.log When I tried the following command , it movies all the log files... (8 Replies)
Discussion started by: frintocf
8 Replies

9. Shell Programming and Scripting

How to check files and move the results to differents files?

Hi, I am a newbie to shell scripting. here is my objective: 1)The shell program should take 2 parameters - ie-> DestinationFolder, WebFolder 2)Destination folder contains few files that has to has be verified and deleted. 3)WebFolder is a folder containing a list of master files 4)It... (1 Reply)
Discussion started by: sandhyagupta
1 Replies
Login or Register to Ask a Question