More formatted string


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting More formatted string
# 1  
Old 05-14-2009
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  
Old 05-14-2009
Code:
awk 'END{print $0}' file| sed 's/^[0-9]0*\(.*\)/\1/g'


cheers,
Devaraj Takhellambam
# 3  
Old 05-14-2009
Or:

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

Regards
# 4  
Old 05-14-2009
if its large file, use tail
Code:
tail -1 largefile | sed ......

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help creating well-formatted columns

Hi all I'm having a few issues with sorting some data into easily-readable columns. Original data in file: Number of visits IP Address 8 244.44.145.122 8 234.45.165.125 6 225.107.26.10 I firstly tried the column -t command which results in this: Number of ... (4 Replies)
Discussion started by: semaj
4 Replies

2. Shell Programming and Scripting

How to get the formatted string with reg?

Source is " LG 0 0 18 14 172.16.2.20 1 2 OK T OK T OK T" How to get the following format string with reg? LG 0 0, 18 Thanks in advance. (10 Replies)
Discussion started by: janex
10 Replies

3. UNIX for Dummies Questions & Answers

Request for Formatted Output

Can you please tell me how to just get only the output of dealers I & V information along with their subtotals in the next line of the file and create a new file, The dealer position along with corresponding totals may change everyday to any position above or below in the file, please help Thanks (2 Replies)
Discussion started by: Ariean
2 Replies

4. UNIX for Advanced & Expert Users

A formatted df script or alias ... ???

Hi gurus, Does anyone have a df script/alias that is sort of "universal"? Just getting frustrated to use bdf for HP-UX, df -h for Linux and Solaris, df -G/g (???) for AIX ... and to make things even worse, some are NFS mount points or with long logical volume name and it extends over two (2)... (1 Reply)
Discussion started by: newbie_01
1 Replies

5. Shell Programming and Scripting

String searching and output to a file in a formatted text

Hi, I'm very new to UNIX scripting and find quite difficult to understand simple UNIX syntax. Really appreciat if somebody could help me to give simple codes for my below problems:- 1) I need to search for a string "TTOH 8031950001" in a files which filename will be "*host*'. For example, the... (3 Replies)
Discussion started by: cuji
3 Replies

6. UNIX for Dummies Questions & Answers

Finding string and getting formatted ouput

I have follwoing text file as alarm dump. A1/EXT "B25I11K0150_F W" 512 090629 1121 RADIO X-CEIVER ADMINISTRATION BTS EXTERNAL FAULT MO RSITE CLASS RXOCF-405 DKRD01_INDS 1 EXTERNAL ALARM MAINS FAIL ... (1 Reply)
Discussion started by: lalchand
1 Replies

7. Shell Programming and Scripting

csh formatted strings

Hi, currently I'm trying to write a csh script that should do the following: set i = 1 while ($i < 100) { cp AAA BBB set i = $i +1 } where AAA is a string like this file.11.txt, file.21.txt, ... and BBB is a string like this file_0001, file_0002, ... Is it possible to... (1 Reply)
Discussion started by: sera1711
1 Replies

8. Shell Programming and Scripting

Formatted Output

Hi I have the following lines in a file SWPRC000001NOT STATED 1344 SWPRC000001NOT STATED 1362 SWPRC000001NOT STATED 1418 SWPRC000001NOT STATED 1436 SWPRC000001NOT STATED ... (6 Replies)
Discussion started by: dhanamurthy
6 Replies

9. Shell Programming and Scripting

Convert DATE string to a formatted text

Hi guys, i need your help. I need to convert a date like this one 20071003071023 , to a formated date like 20071003 07:10:23 . Could this be possible ? Regards, Osramos (6 Replies)
Discussion started by: osramos
6 Replies

10. Shell Programming and Scripting

Formatted output in KSH

Hi, Is there some way to get formatted output in ksh? Something like a properly alligned tabular format. I tried adding '\t' to echo statements, but it doesn't come properly alligned 'hello' A simple Hello 'helloworld' A helloworld statement I need the second coloumn to... (1 Reply)
Discussion started by: psynaps3
1 Replies
Login or Register to Ask a Question