The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to convert C source from 8bit chars to 16bit chars? siegfried Shell Programming and Scripting 0 09-26-2007 11:26 AM
catching some errors bebop1111116 Shell Programming and Scripting 5 09-29-2006 10:12 AM
Catching all Exit Codes Sivaswami J Shell Programming and Scripting 3 02-16-2006 04:13 PM
Catching signal and piping joseph_ng High Level Programming 7 11-14-2005 08:04 AM
catching interrupts toughguy2handle UNIX for Dummies Questions & Answers 1 09-19-2005 12:17 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #8  
Old 11-21-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,003
Quote:
Originally Posted by rkl1
since I dont have much experience in any thing: I will do this work in a simple but long way: so laughing is allowed looking at my code.

for file in `cat t40.txt|nawk '{print $3}'`;do
n=`echo $file|wc -C`
n=`expr $n - 1`
n1=`expr $n - 1`
echo $file|cut -c $n1-$n

I dont know why wc -C brings one more number than the real number of characters are there.

echo "this"|wc -C

this gives value 5 instead of 4.

thanks.

Have you tried running this code?
Reply With Quote
Forum Sponsor
  #9  
Old 11-21-2005
Registered User
 

Join Date: Nov 2005
Posts: 6
I forgot to include the syntax done at the end of the script.

thanks.
Reply With Quote
  #10  
Old 11-22-2005
Registered User
 

Join Date: Jun 2005
Location: Alexandria, Scotland
Posts: 46
awk last characters

Thanks, I tried both the:...

nawk '{print substr($0, length($0)-1)}' text.file

and also the

sed 's/^.*\(..\)$/\1/' text.file

and both these work

rkL1 ---thanks for your input, but these simpler methods works fine...

thanks to all for your speedy responses'
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0