Pring starting and ending numbers using UNIX | Unix Linux Forums | UNIX for Advanced & Expert Users

  Go Back    


UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

Pring starting and ending numbers using UNIX

UNIX for Advanced & Expert Users


Tags
ksh bash, unix

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-15-2013
jackbell2013 jackbell2013 is offline
Registered User
 
Join Date: Sep 2013
Last Activity: 19 September 2013, 2:11 PM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Sun Pring starting and ending numbers using UNIX

Hi all,

I need to do scrip for printing starting and ending numbers along with count in given file.

Input: a.txt


Code:
10000030
10000029
10000028
10000027
10000026
10000024
10000023
10000021
10000018
10000018
10000017
10000016
10000015
10000014
10000013
10000011
10000010
10000009
10000008
10000006
10000005
10000004
10000003
10000002
10000001

Output needed : out.txt


Code:
starting,Ending,count

10000001,10000006,6
10000008,10000011,4
10000013,10000019,7
10000021,10000021,1
10000023,10000024,2
10000026,10000030,5

Plz help me to solve this scrip

Last edited by Scrutinizer; 09-15-2013 at 02:00 PM.. Reason: code tags
Sponsored Links
    #2  
Old 09-15-2013
Don Cragun's Avatar
Don Cragun Don Cragun is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 31 July 2014, 7:16 AM EDT
Location: San Jose, CA, USA
Posts: 4,200
Thanks: 164
Thanked 1,430 Times in 1,213 Posts
Is this a homework assignment?
If it isn't homework, what is the reason for needing to do this?

In this sample, the input is in reverse sorted numeric order. Will that always be true with your input data?

Will the input always only be 8 digit numbers?
Sponsored Links
    #3  
Old 09-16-2013
jackbell2013 jackbell2013 is offline
Registered User
 
Join Date: Sep 2013
Last Activity: 19 September 2013, 2:11 PM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Don,

Thanks for your reply...

Yes this is for my UNIX class work. my teacher ask me to do some scripts.so i try this but i struck....

Input will not be arranged as above it be in any kind of order and we ll use sort command to sort in wanted format..

No, my input digit is up to 0 to 12 digits some time..
Moderator's Comments:
Homework can only be posted in the Homework & Coursework Questions Forum and must include your full school name, professor, and course number. Please refile this request in the Homework & Coursework Questions Forum.

Last edited by Don Cragun; 09-16-2013 at 10:50 AM.. Reason: Homework violation.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Sorting files ending in numbers with "sort" newbie2010 UNIX for Dummies Questions & Answers 6 06-04-2013 11:16 AM
if statement to check files with different ending but same starting name ningy Shell Programming and Scripting 5 10-25-2011 05:15 AM
Help in retrieving the ending line numbers of the functions abk07 Shell Programming and Scripting 7 06-12-2011 01:34 PM
Deleting lines not starting with numbers with sed drbiloukos Shell Programming and Scripting 4 12-24-2010 06:41 AM
perl: reg.expr: combine starting and ending removal in one exprecion alex_5161 Shell Programming and Scripting 2 08-27-2009 11:51 AM



All times are GMT -4. The time now is 07:27 AM.