[Solved] Assign file name = to string in a different file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Solved] Assign file name = to string in a different file
# 1  
Old 06-24-2013
[Solved] Assign file name = to string in a different file

I have two files:
pgmname.ou1 - contains invoice data
pgmname.ou2 - contains unique file name for pgmname.ou1

I want to copy pgmname.ou1 to a file with the name specified in pgmname.ou2.
So if pgmname.ou2 has a line in it with the following data:
FILE.NAME.UNIQUE.csv
I want to:
Code:
cpy pgmname.ou1 FILE.NAME.UNIQUE.csv

How can I do this? Thx in advance.
# 2  
Old 06-24-2013
Code:
n12:/home/vbe/test $ mv pgname1 $(cat pgname2)   # or cp...
n12:/home/vbe/test $ ll FILE.NAME.UNIQUE.csv
-rw-rw-r--    1 vbe      sds            0 Jun 24 18:40 FILE.NAME.UNIQUE.csv

This of course if you are sure you have at least AND only one line in your second file... My pgname1 was issued with touch command so 0 for size...
And of course using cat you could initialize a variable and use that vairable for the copy...
# 3  
Old 06-24-2013
Thanks so much. Was simpler than I thought.

Tried assigning the name to a variable which worked.
Code:
FILENAME=$(cat $wrk_dir/pgmname.ou2)

Instead decided to copy it right to the destination directory.
Code:
cp $wrk_dir/pgmname.ou1 $dest_dir"/"$(cat $wrk_dir/pgmname.ou2)

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace string of a file with a string of another file for matches using grep,sed,awk

I have a file comp.pkglist which mention package version and release . In 'version change' and 'release change' line there are two versions 'old' and 'new' Version Change: --> Release Change: --> cat comp.pkglist Package list: nss-util-devel-3.28.4-1.el6_9.x86_64 Version Change: 3.28.4 -->... (1 Reply)
Discussion started by: Paras Pandey
1 Replies

2. Shell Programming and Scripting

Removing string from CSV file by provide removal string from other file

What I need is to remove the text from Location_file.txt from each line matching all entries from Remove_location.txt Location_file.txt FlowPrePaid, h3nmg1cm2,Jamaica_MTAImageFileFlowPrePaid,h0nmg1cm1, Flow_BeatTest,FlowRockTest FlowNewTest,FlowNewTest,h0nmg1cm1 PartiallySubscribed,... (3 Replies)
Discussion started by: ketanraut
3 Replies

3. Shell Programming and Scripting

How to read each line from input file, assign variables, and echo to output file?

I've got a file that looks like this (spaces before first entries intentional): 12345650-000005000GL140227 ANNUAL HELC FEE EN 22345650-000005000GL140227 ANNUAL HELC FEE EN 32345650-000005000GL140227 ANNUAL HELC FEE EN I want to read through the file line by line,... (6 Replies)
Discussion started by: Scottie1954
6 Replies

4. Shell Programming and Scripting

[Solved] How to get file name which contains certain string?

Hi Gurus, I need find which file contains certain string in one directory. when using cat * |grep "string", I can get the string name but no file name displayed. I am wondering if there is any option I can use to get which file contains this certain string. Thanks in advance. (3 Replies)
Discussion started by: ken6503
3 Replies

5. Shell Programming and Scripting

[solved] File type error (not a regular file)

Hi friend, i have written script as below to check the file existance. but i got error path="/k/p1100/users/jewel/Output" FILENAME=`ls -lrt $path/*HT|tail -1|cut -d "/" -f 8` if ; then echo "$FILENAME is available " chmod 755 $path/$FILENAME /usr/bin/scp... (0 Replies)
Discussion started by: Jewel
0 Replies

6. Programming

[Solved] Removing duplicates from the file and saving as new file

Dear All I have 200 data files and each files has many duplicates. I am looking for the automated awk script such that it checks and removes the duplicates from the each file and saving them as new files for all 200 files in the respective folder. For example my data looks like this.. ... (12 Replies)
Discussion started by: bala06
12 Replies

7. Shell Programming and Scripting

replace (sed?) a single line/string in file with multiple lines (string) from another file??

Can someone tell me how I can do this? e.g: Say file1.txt contains: today is monday the 22 of NOVEMBER 2010 and file2.txt contains: the 11th month of How do i replace the word NOVEMBER with (5 Replies)
Discussion started by: tuathan
5 Replies

8. Shell Programming and Scripting

[solved] merging two files and writing to another file- solved

i have two files as file1: 1 2 3 file2: a b c and the output should be: file3: 1~a 2~b 3~c (1 Reply)
Discussion started by: mlpathir
1 Replies

9. Shell Programming and Scripting

Extracting particular string in a file and storing matched string in output file

Hi , I have input file and i want to extract below strings <msisdn xmlns="">0492001956</ msisdn> => numaber inside brackets <resCode>3000</resCode> => 3000 needs to be extracted <resMessage>Request time getBalances_PSM.c(37): d out</resMessage></ns2:getBalancesResponse> => the word... (14 Replies)
Discussion started by: sushmab82
14 Replies

10. Shell Programming and Scripting

How To Replace A String In File With A String Containing Windows File Path

Hi, I have a file with the following contents # Lines that start with a # are comments. # # Calling TOAD like this will perform a comparison from command line : # # "C:\Program Files\Quest Software\Toad for Oracle 9.6\toad.exe" -c... (2 Replies)
Discussion started by: rajan_san
2 Replies
Login or Register to Ask a Question