troubleshooting Question

replace the column feild in the souce file to have different target file in unix/pearl script

Avatar of welcome 123
welcome 123 asked on
PerlShell ScriptingMicrosoft SQL Server 2005
15 Comments1 Solution356 ViewsLast Modified:
Hi,

I want script in unix/pearl

My source file:

50|20130430|xxxx|||COOKING OIL|SALT|CUP|SPOON|BED SHEET
60|20130430|YYYY||GOLD|GROUND NUT OL|PEPER|MUG|STEEL SPOON|PILLOW
75|20130430|EXPPP|NA|IRON|SUNFLOWER OIL|RED PEPPER|BUCKET|GOLD SPOON|MAT

I want to replace this file 9th column position with value 'L'

the output target should be:

50|20130430|xxxx|||COOKING OIL|SALT|CUP|L|BED SHEET
60|20130430|YYYY||GOLD|GROUND NUT OL|PEPER|MUG|L|PILLOW
75|20130430|EXPPP|NA|IRON|SUNFLOWER OIL|RED PEPPER|BUCKET|L|MAT

but I got the following error when I executed the following script.

>./replace_file.pl -fixed_col=9 -fixed_val='L'

./replace_file.pl: ERROR:
The -fixed_col=9 is not present as the total number of columns in this file is only 2

USAGE:
 Need to specify -fixed_col=<col_num> & -fixed_val=<col_val> switch for changing a column with a particular value or -serial_col=<col_num> switch with just the column number so that the values are incremented serially.
 OR you can also specify all the 3 args for both fixed and serial ... -fixed_col=<col_num> -fixed_val=<col_val> -serial_col=<col_num>
Example:  ./replace_file.pl -fixed_col=3 -fixed_val=EURO -serial_col=5

Please let me know what I missing while executing,.

Thanks in advance.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 15 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros