![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Substr in shell script | gjithin | Shell Programming and Scripting | 7 | 05-10-2008 01:40 PM |
| Help with Korn Shell script | heprox | AIX | 1 | 12-19-2005 10:04 AM |
| korn shell script | pavan_test | UNIX Desktop for Dummies Questions & Answers | 3 | 10-27-2005 09:09 AM |
| korn shell script | pavan_test | UNIX for Dummies Questions & Answers | 1 | 10-26-2005 10:17 AM |
| Trouble using substr function with Bourne shell script | E2004 | Shell Programming and Scripting | 4 | 09-29-2005 07:57 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
substr() thru awk Korn Shell Script
Hi,
I am new stuff to learn substr() function through awk for writing the Korn shell script. Is there a way to copy from XXXX1234.ABCDEF to XXX1234 file names without changing both data files? I appreciate your time to response this email. Thanks, Steve |
| Forum Sponsor | ||
|
|
|
|||
|
I don't understand your question
Are you copying a file named "XXXX1234.ABCDEF" to "XXX1234"? (#1) Or are you transforming one file to another and transforming the contents from "XXXX1234.ABCDEF" to "XXX1234"? (#2) And did you mean to have 4 X's in the first and 3 in the second? If #2 above, must you use korn/awk? Any of python/ruby/perl/sed would do the job as well. -- Qman |
|
|||
|
substr() thru awk Korn Shell Script
Hi qneill,
Thanks for your time to review my post. I knew I am not clear myself because I am not a techie person. This morning, I reviewed the Similar Thread section and found a solution to separate the file name fields using the awk command. For example, a file named “XXXX.12345.YYYY” must be changed to “XXXX.12345”. The echo result of the command line as echo “XXXX.12345.YYYY” | `awk –F. ‘{print $1}’` is “XXXX”. However, I need to use the same command line above for combining the first two fields of the file named “XXXX.12345” Is there a way to show the results of the first two fields of the file name? Thanks, sbryant |