Copy range of directory name


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Copy range of directory name
# 1  
Old 12-15-2009
Bug Copy range of directory name

Hello folks hope all are doing well, i need to compress directories with range, i have total directories from 000-199

and i want to copy directories from 010 onwards to 020 meants total 11 directories, please suggest what regex will i use.

Thanks,
Bash
# 2  
Old 12-15-2009
Code:
#!/bin/ksh

typeset -z3 num

num=10

while [[ $num -lt 21 ]]; do

  cp $num somewhere_else/$num

  (( num += 1 ))

done

not regexp but you'd need to specify language...

you could do:

Code:
/bin/ls -1d 0?? | egrep '(^01|^020)'


Last edited by quirkasaurus; 12-15-2009 at 03:21 PM.. Reason: 1 for l
# 3  
Old 12-15-2009
Code:
tar cvf - 01? 020 |gzip > urfile.tar.gz

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match text in a range and copy value

In the files attached, I am trying to: if Files.txt $1 is in the range of Exons.txt $1, then in Files.txt $4 the value from Exons.txt $3 is copied else if no match is found Exons.txt $3 = "Intron" For example, the first value in File.txt $1 is chr1:14895-14944 and is not found in any range... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. Shell Programming and Scripting

Copy files given a range of numbers

Hi, I have about 500 files in a directory. The filenames are numbered i.e. 1.dat, 2.dat, 3.dat,...,500.dat. I have 5 other empty directories where I have to copy the files in different range of numbers, for example, 1.dat to 300.dat in dir1, or 200.dat to 500.dat in dir2, another example... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

3. UNIX for Dummies Questions & Answers

Awk: how to copy a range of rows in GAMS environment

Hi I have a problem in using awk in GAMS. I have to copy a part of a .txt file selecting the rows between these two lines "0 / END OF TRANSFORMER DATA, BEGIN AREA DATA" "0 / END OF AREA DATA, BEGIN TWO-TERMINAL DC DATA" I thought of using a command like this: $onecho > area.awk... (4 Replies)
Discussion started by: Pintug
4 Replies

4. Shell Programming and Scripting

Copy the files in directory and sub folders as it is to another directory.

How to copy files from one directory to another directory with the subfolders copied. If i have folder1/sub1/sub2/* it needs to copy files to folder2/sub1/sub2/*. I do not want to create sub folders in folder2. Can copy command create them automatically? I tried cp -a and cp -R but did... (4 Replies)
Discussion started by: santosh2626
4 Replies

5. Shell Programming and Scripting

how to copy the directory but not copy certain file

Hi experts cp bin root src /mnt but not copy bin/bigfile any help? ( I post this thread in the "redhat" forum wrongly, I don't know how to withdraw that question in that wrong forum) Thanks (6 Replies)
Discussion started by: yanglei_fage
6 Replies

6. Emergency UNIX and Linux Support

How to move files from a directory which falls between Date Range?

Hi All, I am trying to to move files from a directory to another which falls from Current day - 7 days. The files are in zipped format with dates appended on it. Can you pls help me as this came as a immediate change before the production Release planned next week. Pls let me know if... (11 Replies)
Discussion started by: dsfreddie
11 Replies

7. UNIX for Dummies Questions & Answers

Removing a range of files in a directory..

Hi all, Disclosure: I am very new to Unix, but eager to learn.. I've been tasked with transferring logs to a remote server. After I've verified these logs have transferred correctly I have to remove the source files. The naming scheme is: /directory/2012.05.01 /directory/2012.05.02 ..and... (1 Reply)
Discussion started by: JD3V
1 Replies

8. Shell Programming and Scripting

Grep by range of date from file creation in directory

Hi Expert, Need your scripting and finding data so that it help me to find the culprit of this memory usage error. Data provided here is a sample. Process Snapshot directory: /var/spool/processes-snapshot webdev9o9% pwd /var/spool/processes-snapshot webdev9o9% ls -lrct -rw-r--r-- ... (3 Replies)
Discussion started by: regmaster
3 Replies

9. UNIX for Advanced & Expert Users

How can i copy files by date last modifed range?

When I do a ls -lt I get a list of files by date modified from newest to oldest. I would like to be able to copy some files to another directory using a date last modified range (i.e. Apr 30 - May 13) How could I do this? Thanks, Joe (4 Replies)
Discussion started by: geauxsaints
4 Replies

10. Shell Programming and Scripting

Script that can Copy a Range of files from Tape to Hard disk

Hi: I am a trying to write a script using a loop i guess. What I need to do is write a script that can allow my users to load a tape and copy a range of files from a tape to the hard disk. By range I mean, I would like the users to pick a range of numbers like files 3 - 8 and the script will... (0 Replies)
Discussion started by: msjazzie
0 Replies
Login or Register to Ask a Question