If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Cut command

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-25-11, 02:05
blazer789 blazer789 is offline
Registered User
 
Join Date: Jun 2009
Posts: 221
Cut command

Kindly help me out in getting the desired output for a cut command

For example this is how my file is

specialcase
grateful
cricketplayers
soccerteam

From this file the cut command should only output the last 4 characters of each word. This should be my output

case
eful
yers
team
Reply With Quote
  #2 (permalink)  
Old 02-25-11, 02:06
blazer789 blazer789 is offline
Registered User
 
Join Date: Jun 2009
Posts: 221
Not only the cut command. If it is possible with any other command, that would be helpful.
Reply With Quote
  #3 (permalink)  
Old 02-25-11, 05:58
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
substr('grateful',len(grateful)-4)

HTH

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #4 (permalink)  
Old 02-25-11, 05:58
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
oops ... you can do right('grateful',4)

cheers

sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #5 (permalink)  
Old 02-25-11, 06:49
blazer789 blazer789 is offline
Registered User
 
Join Date: Jun 2009
Posts: 221
Thanks Satyaram. Your answer reflects to a single word. But I have a file named test

this is how file looks like

$cat test

specialcase
grateful
cricketplayers
soccerteam


Now I need a command to execute on that file so that the output would be

case
eful
yers
team
Reply With Quote
  #6 (permalink)  
Old 03-01-11, 05:25
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
cut

this is a db2 forum and has nothing todo with cut command from linux/unix o/s
check in the forum about shell command for that system.
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On