![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Getting Following problem when opening shell script (Very Urgent) | sunitachoudhury | Shell Programming and Scripting | 1 | 03-31-2008 07:01 AM |
| shell script performance issues --Urgent | icefish | Shell Programming and Scripting | 18 | 12-14-2007 10:43 AM |
| Urgent help needed - shell script | aarora_98 | SUN Solaris | 3 | 01-25-2007 02:26 PM |
| Calling CGI Perl in Shell script [urgent] | DeepakXavier | Shell Programming and Scripting | 0 | 10-09-2005 01:51 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Urgent for shell script
Hi friends,
I am working as a DataStage developer. I need help in writing shell script. I have following file and I want to remove data from 1st field and store it into other file. Convert this file, A100 Tylenol 100mg A100 PCML 500mg B120 CFDR 250mg C345 PFLX 600mg remove 1st column data to Tylenol 100mg PCML 500mg CFDR 250mg PFLX 600mg can anyone help me? thanks sunny |
|
||||
|
maybe this is what you wanted??
Code:
#> cat sunny
A100 Tylenol 100mg
A100 PCML 500mg
B120 CFDR 250mg
C345 PFLX 600mg
#> awk '{print $1 > "sunny.out"} ; {print $2,$3} ' sunny
Tylenol 100mg
PCML 500mg
CFDR 250mg
PFLX 600mg
#> cat sunny.out
A100
A100
B120
C345
|
|
||||
|
thanks for the solution timj123.
this work if i have know number of columns, what if i don't know how many columns are in this file. this file is ftped to us everyday and i have to remove 1st field data from the file. It may possible that number of columns will be different each time let me know ur input. thanks sunny |
|
||||
|
Code:
2:39pm # cat data
A100 Tylenol 100mg
A100 PCML 500mg
B120 CFDR 250mg
C345 PFLX 600mg
2:39pm # awk '{print $1 > "data.OUT"} ; {a=""; for (i=2;i<=NF;i++) {a=a $i " "} print a} ' data > data.OK
2:40pm # cat data.OK
Tylenol 100mg
PCML 500mg
CFDR 250mg
PFLX 600mg
2:40pm # cat data.OUT
A100
A100
B120
C345
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|