The UNIX and Linux Forums  


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
csh formatted strings sera1711 Shell Programming and Scripting 1 01-06-2009 01:38 AM
Formatted Output dhanamurthy Shell Programming and Scripting 6 05-13-2008 03:30 AM
Formatted output - awk dhanamurthy Shell Programming and Scripting 3 05-12-2008 12:25 AM
Convert DATE string to a formatted text osramos Shell Programming and Scripting 6 10-10-2007 06:31 AM
Formatted output in KSH psynaps3 Shell Programming and Scripting 1 07-05-2006 09:03 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 05-14-2009
ford2020 ford2020 is offline
Registered User
  
 

Join Date: May 2009
Posts: 18
More formatted string

In a large file i need last line of the file but I want ignore first charcter, ignore leading zeros after first character and print the remaining character as such. Is something i can do it by tail or wc?
cat test1
....
......
8000003687
cat test2
....
......
8000538990
o/p
3687
538990
  #2 (permalink)  
Old 05-14-2009
devtakh devtakh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore
Posts: 514

Code:
awk 'END{print $0}' file| sed 's/^[0-9]0*\(.*\)/\1/g'


cheers,
Devaraj Takhellambam
  #3 (permalink)  
Old 05-14-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,342
Or:


Code:
awk 'END{printf("%d\n",int(substr($0,2)))}'

Regards
  #4 (permalink)  
Old 05-14-2009
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,557
if its large file, use tail

Code:
tail -1 largefile | sed ......

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:10 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