The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-03-2008
sunnysunny sunnysunny is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 5
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
  #2 (permalink)  
Old 03-04-2008
timj123 timj123 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 80
Code:
awk '{print $2,$3} ' sunny
Tylenol 100mg
PCML 500mg
CFDR 250mg
PFLX 600mg
  #3 (permalink)  
Old 03-04-2008
timj123 timj123 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 80
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
  #4 (permalink)  
Old 03-04-2008
sunnysunny sunnysunny is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 5
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
  #5 (permalink)  
Old 03-04-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,421
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0