Regular Expression to copy files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Regular Expression to copy files
# 1  
Old 09-15-2010
Regular Expression to copy files

Hi All,

I have a file with the contents as below.
Code:
Current_path/file1
Current_path/file2
Current_path/file3

Now i want a regular expression to copy this files to
Code:
cp Current_path/file1   HOME_DIR/Current_path/file1
cp Current_path/file2   HOME_DIR/Current_path/file2
cp Current_path/file3   HOME_DIR/Current_path/file3


Could you guys please help me to do this.

Thanks in advance,
Girish.

Last edited by Franklin52; 09-15-2010 at 03:14 AM.. Reason: Please use code tags!
# 2  
Old 09-15-2010
Quote:
Originally Posted by girish.raos
Hi All,

I have a file with the contents as below.
Code:
Current_path/file1
Current_path/file2
Current_path/file3

Now i want a regular expression to copy this files to
Code:
cp Current_path/file1   HOME_DIR/Current_path/file1
cp Current_path/file2   HOME_DIR/Current_path/file2
cp Current_path/file3   HOME_DIR/Current_path/file3


Could you guys please help me to do this.

Thanks in advance,
Girish.
Try it first without the colored part:
Code:
sed 's#\(.*\)#cp & HOME/DIR/&#' file | sh

# 3  
Old 09-15-2010
I thinks you don't need regexes for this:
Code:
cat file | cpio -pumd $HOME

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find regular expression for two files?

I have files: sum_<INPUT FILENAME>.YYYYMMDDhhmmss.csv and sum_details_<INPUT FILENAME>.YYYYMMDDhhmmss.csv I have no idea, what is input filename, but in the code I would like to catch them in case I process them in the loop above case statement for *.${Today}.*.txt... (3 Replies)
Discussion started by: digioleg54
3 Replies

2. Shell Programming and Scripting

Sed: Splitting A large File into smaller files based on recursive Regular Expression match

I will simplify the explaination a bit, I need to parse through a 87m file - I have a single text file in the form of : <NAME>house........ SOMETEXT SOMETEXT SOMETEXT . . . . </script> MORETEXT MORETEXT . . . (6 Replies)
Discussion started by: sumguy
6 Replies

3. Homework & Coursework Questions

Regular Expression to match files in Perl

Hi Everybody! I need some help with a regular expression in Perl that will match files named messages, but also files named message.1, message.2 and so on. So really I need one that will find messages and messages that might be followed by a period and a digit without matching other files like... (2 Replies)
Discussion started by: Hax0rc1ph3r
2 Replies

4. UNIX for Advanced & Expert Users

sed: -e expression #1, char 0: no previous regular expression

Hello All, I'm trying to extract the lines between two consecutive elements of an array from a file. My array looks like: problem_arr=(PRS111 PRS213 PRS234) j=0 while } ] do k=`expr $j + 1` sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt ---some operation goes... (11 Replies)
Discussion started by: InduInduIndu
11 Replies

5. UNIX for Dummies Questions & Answers

Compare files with regular expression

Readers, Reading a previous post about comparing files using awk ('awk-compare-2-columns-2-files-output-whole-line', https://www.unix.com/shell-programming-scripting/168432-awk-compare-2-columns-2-files-output-whole-line.html), it is possible to adjust this, so that regular expression can be used... (8 Replies)
Discussion started by: linuxr
8 Replies

6. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

7. Shell Programming and Scripting

copying files using regular expression

I have 3 files names as HU123.IHS ,SU345.IHS DU567.IHS I have written a script to copy the files to the destination server but I am getting the error. /bin/cp '/dun/homes/11.3.7/packages/HU*.IHS' /dun/homes/11.3.7/Target But I am getting one error :- /bin/cp: cannot stat... (1 Reply)
Discussion started by: maitree
1 Replies

8. Shell Programming and Scripting

search a regular expression and match in two (or more files) using bash

Dear all, I have a specific problem that I don't quite understand how to solve. I have two files, both of the same format: XXXXXX_FIND1 bla bla bla bla bla bla bla bla bla bla bla bla ======== (return) XXXXXX_FIND2 bla bla bla bla bla bla (10 Replies)
Discussion started by: TheTransporter
10 Replies

9. Shell Programming and Scripting

Integer expression expected: with regular expression

CA_RELEASE has a value of 6. I need to check if that this is a numeric value. if not error. source $CA_VERSION_DATA if * ] then echo "CA_RELESE $CA_RELEASE is invalid" exit -1 fi + source /etc/ncgl/ca_version_data ++ CA_PRODUCT_ID=samxts ++ CA_RELEASE=6 ++ CA_WEEK_NO=7 ++... (3 Replies)
Discussion started by: ketkee1985
3 Replies

10. Shell Programming and Scripting

How to apply a regular expression in all the files in a directory

I have say 100 text files (with .txt extension) in a directory. An example of the content in the file is given below "NAME" "cgd1_200" "cgd1_3210" "cgd1_560" "cgd2_2760" "cgd2_290" "cgd3_3210" "cgd3_3310" "cgd3_660" "cgd5_2130" "cgd5_4080" "cgd6_3690" "cgd6_4480" "cgd8_1540"... (2 Replies)
Discussion started by: Lucky Ali
2 Replies
Login or Register to Ask a Question