BladeSystem Forums have moved here
To make BladeSystem information easier to find, we have moved the BladeSystem forums here, to Servers and Operating Systems.
Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

list the file need for syntex

Super Advisor

list the file need for syntex

[ Edited ]

i want to list the file from 1_11_data01.dbf to 1_78_data01.dbf

and i need to copy the same file to some other location. please advise the command

 

1.list command

2.copy command

 

example file name

 

1_10_data01.dbf

1_11_data01.dbf

1_12_data01.dbf

1_13_data01.dbf

1_14_data01.dbf

1_15_data01.dbf

1_16_data01.dbf

1_17_data01.dbf

1_18_data01.dbf

1_20_data01.dbf

.

.

.

1_300_data01.dbf

 

3 REPLIES
Honored Contributor

Re: list the file need for syntex

if they are not in the same directory.

 

find $pathwherethefilesare -name 1_\*_data01.dbf -exec cp {} targetdir \;

 

 

or:

find $pathwherethefilesare -name 1_\*_data01.dbf >/tmp/listfile

 

cp $(cat /tmp/listfile) targetdir

 

or many other

Honored Contributor

Re: list the file need for syntex

If you want to list that specific range of file, you can do something like:

 

ls 1_[1-7][0-9]_data01.dbf

 

This will give you all files in the range 1_10_data01.dbf through 1_79_data01.dbf.

 

You can use the same syntax with the brackets in a 'cp' command.

Highlighted
Acclaimed Contributor

Re: list the file need for syntax

>I want to list the file from 1_11_data01.dbf to 1_78_data01.dbf

 

If you only want these and not the edges given by Patrick's regex slice, then you need a script.  Or use grep to remove the 3 files that you don't want.

 

list_data_files.sh:

#!/usr/bin/ksh

# Lists files from 1_11_data01.dbf to 1_78_data01.dbf

 

(( index = 11 ))

while (( index <= 78 )); do

   if [ -f 1_${index}_data01.dbf ]; then  # check if there

      echo "1_${index}_data01.dbf \c"

   fi

   (( index += 1 ))

done

 

Then to list or cp you can use:

ls $(list_data_files.sh)

cp $(list_data_files.sh) targetdir

 

>cp $(cat /tmp/listfile) targetdir

 

So close, you left an evil cat there.  ;-)

cp $(< /tmp/listfile) targetdir