Replacing Data in a File


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replacing Data in a File
# 8  
Old 09-18-2012
Quote:
Originally Posted by asheshrocky
I still face some issue passing the Input file name to the script.I believe the issue is because its too big.

/bin/bash ./test.sh /home/ntp_home/e701152/sapphire/wet/prodstag/stageWork/FAB8_NoCustomerCode
awk -F | NF == 13 && $0 !~ /^#/ { $12=50}1 OFS=|

The Filename name is Broken after No Customer Code.Actually the Filename runs much longer.

Fullname : FAB8_NoCustomerCode_RIPCORD1.01_8XYJ09015.000_C4-WETILT.01_E-RPCRD1-RERM-01-C4-025-ALL-01_11_EGBNE088TMC5_20120814-232625.limit.wcal.dis
What you tried..?
# 9  
Old 09-18-2012
I did try the same code which u mentioned in your previous entry ...

Code:
#!/bin/bash        
file_name=$(awk -F "[<>]" '/<Param id="LimitDis">/{print $3}' input_file)
echo $file_name > testfile.txt
awk -F "|" 'NF == 13 && $0 !~ /^#/ { $12=50}1' OFS=\| $file_name > temp_file
mv temp_file $file_name

---------- Post updated at 03:51 AM ---------- Previous update was at 03:50 AM ----------

This is how am passing the value to the Script :

Code:
<Script id="Dispo">
  <WorkDir>/home/ntp_home/e701152/sapphire/wet/progs/JCalPara</WorkDir>
  <ExecCmd>./test.sh</ExecCmd>
  <TimeOut>600</TimeOut>
  
  <Param id="LimitDis">${StageWork}/dis/${WaferNC}.limit.dis</Param> 
 </Script>

# 10  
Old 09-18-2012
ok try using double quotes and print file output..

what you get as file_name..? ( check if this is the file you want to perform operation on it..?)

Code:
#!/bin/bash        
file_name=$(awk -F "[<>]" '/<Param id="LimitDis">/{print $3}' input_file)
echo $file_name > testfile.txt
echo "$file_name"
awk -F "|" 'NF == 13 && $0 !~ /^#/ { $12=50}1' OFS=\| "$file_name" > temp_file
mv temp_file "$file_name"

# 11  
Old 09-18-2012
Hi Pamu,

Code:
echo "$file_name" > inputfile.txt

The code just hangs here and when i kill the process and check inputfile.txt its blank.Nothing is been written into it .

A error file is also generated saying No such filename is found.

---------- Post updated at 04:21 AM ---------- Previous update was at 04:20 AM ----------

when i do ps ux i see only half of file name is passed to application ,

/bin/bash ./test.sh /home/ntp_home/e701152/sapphire/wet/prodstag/stageWork/FAB8_NoCustomerCod
# 12  
Old 09-18-2012
Quote:
Originally Posted by asheshrocky
A error file is also generated saying No such filename is found.
Are you providing right filename to the awk...?
check the input_file. I think this a reason for the error...
Code:
#!/bin/bash        
file_name=$(awk -F "[<>]" '/<Param id="LimitDis">/{print $3}' input_file)
echo $file_name > testfile.txt
awk -F "|" 'NF == 13 && $0 !~ /^#/ { $12=50}1' OFS=\| $file_name > temp_file
mv temp_file $file_name

# 13  
Old 09-18-2012
Oh,May i know what u expect at this place .....
I pass the Filename only from the Script....

Code:
<Script id="Dispo">
  <WorkDir>/home/ntp_home/e701152/sapphire/wet/progs/JCalPara</WorkDir>
  <ExecCmd>./test.sh</ExecCmd>
  <TimeOut>600</TimeOut>
  
  <Param id="LimitDis">${StageWork}/dis/${WaferNC}.limit.dis</Param> 
 </Script

The line mentioned in red will give the correct filename and its also correct.I have verified that .Does this replace the input_file field u highlighted in your post ?
# 14  
Old 09-18-2012
I am also getting confused..

what is result of this..
Code:
awk -F "[<>]" '/<Param id="LimitDis">/{print $3}' input_file

This User Gave Thanks to pamu For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replacing 12 columns of one file by second file based on mapping in third file

i have a real data prod file with 80+ fields containing 1k -2k records. i have to extract say 12 columns out of this which are sensitive fields along with one primary key say SEQ_ID (like DOB,account no, name, SEQ_ID, govtid etc) in a lookup file. i have to replace these sensitive fields in... (11 Replies)
Discussion started by: megh12
11 Replies

2. Shell Programming and Scripting

Replace data of a file with data from another file using shell scripting.

Dears, I'm new to shell scripting and i was wondering if you can help me with following matter. I have a file containing 400,000 records. The file contains two columns like: 00611291,0270404000005453 25262597,1580401000016155 25779812,1700403000001786 00388934,1200408000000880... (1 Reply)
Discussion started by: paniklas
1 Replies

3. UNIX for Dummies Questions & Answers

Mapping a data in a file and delete line in source file if data does not exist.

Hi Guys, Please help me with my problem here: I have a source file: 1212 23232 343434 ASAS1 4 3212 23232 343434 ASAS2 4 3234 23232 343434 QWQW1 4 1134 23232 343434 QWQW2 4 3212 23232 343434 QWQW3 4 and a mapping... (4 Replies)
Discussion started by: kokoro
4 Replies

4. Shell Programming and Scripting

Replacing data in one file with data in another

Hello, I have 2 files delimited by "|". File1: 1|New York 12| Buffalo 599| Syracuse File2: 56 Kennedy |1 9 Burridge Pl|15 98 BELL ROCK |599 My goal: Is to replace the numerical numbers in "File 2" (second field, not street address) with the corresponding city names from... (2 Replies)
Discussion started by: vestport
2 Replies

5. Shell Programming and Scripting

Help in replacing two blank lines with two lines of diff data

Hi.. I'm facing a trouble in replacing two blank lines in a file using shell script... I used sed to search a line and insert two blank lines after the searchd line using the following sed command. sed "/data/{G;G;}/" filename . In the file, after data tag, two lines got inserted blank lines..... (4 Replies)
Discussion started by: arjun_arippa
4 Replies

6. Shell Programming and Scripting

Help in replacing two blank lines with two diff data

Hi.. I'm facing a trouble in replacing two blank lines in a file using shell script... I used sed to search a line and insert two blank lines after the searchd line using the following sed command. Sed "/data/{G;G;}/" filename. In the file, after data tag, two lines got inserted blank lines.. Now... (1 Reply)
Discussion started by: arjun_arippa
1 Replies

7. Shell Programming and Scripting

Replacing Comma delimiter coming inside the data.

Hello, I am having flat file (Comma Delimiter) and the data in the file is as given below. EMPNO, ENAME, DESIGNATION, SALARY 10979, Arun Kumar, Cosultant, 35000 13555, Bidhu Shekar, Senior Consultant, 45000 15000, Kiran, Kumar, Senior, Consultant, 40000 If... (9 Replies)
Discussion started by: arunvasu2
9 Replies

8. Shell Programming and Scripting

Find and replace data in text file with data in same file

OK I will do my best to explain what I need help with. I am trying to format an ldif file so I can import it into Oracle oid. I need the file to look like this example. Keep in mind there are 3000 of these in the file. changetype: modify replace: userpassword dn:... (0 Replies)
Discussion started by: timothyha22
0 Replies

9. Shell Programming and Scripting

Replacing data of output file with input

Hi, I have a ksh which peocess and get me data from 3 days... ie if i process it on jan 28.. it gets data for 25, 26 and 27.... the process run every day and get previous 3 days data...all this data is appened to a file lets call time.out Now time.out cannot have deplicate data so what i want... (10 Replies)
Discussion started by: bhagya2340
10 Replies

10. Shell Programming and Scripting

Replacing the last data of each line ina file

Hi, I ahve a file where the format is as given below: qqq dfsf gdfjkg gjdosjg jkflsjd 21 fdksdlf fsdnkfl lkdfsgjld 45 laefsdl fsdlfksl fsdklflk gfsdl 56 I need to replace the last number by space or delete the last number in each line. (by using... (6 Replies)
Discussion started by: jisha
6 Replies
Login or Register to Ask a Question