Range generator

Login or Register for Dates, Times and to Reply

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Range generator
# 1  
Range generator

Dear All,
I have a sorted file like


The output will be range like

1 3
8 10
45 47
78 78
# 2  
Did you have a question? Where are you stuck?
# 3  
Actually, forget it. I see you are one of those persons that just posts your requirements and waits for someone else to just write your code or tell you how to do it. I don't help people like that. Someone else will probably do your work for you, but not me.

# 4  
i am waiting for any clue. If you are not interested just forget it my friend.
# 5  
Dear all,
any idea how to resolve this problem?
# 6  
awk '{ if( NR == 1 ) start=$1;if(NR != 1 && $1 != (prev+1)) {print start,prev;start=$1;}prev=$1}END{print start,prev}' infile

# 7  
Don't do people's homework assignments!

It is against the Unix forum policy and just encourages them to keep coming back and continue posting homework problems to be done by the very helpful and well meaning people here.

To those posting your homework, you're not learning anything by doing that. If your response is that you don't want to learn this stuff, then reconsider the career path that you are on that would require you to take courses and learn things that you inherently aren't interested in. It is a sad existence that you are setting yourself up for.

To those that help these people, consider that someday you will have to hire someone with Unix scripting experience. Would you prefer to have someone who has actually struggled with the vagaries of scripting in Unix/Linux, who asked for and learned from the help they received when they got stuck, or do you want someone who posted all their homework to some web forum so someone else could do all the work and they learned nothing. I guess what I am saying is that you are setting yourself up (or one of us) for that situation.

And it will SUCK!

Look, I know that scripting in Unix isn't easy. Programming is an inherently challenging task. Using Unix and Linux to do real work is tough. I love these forums because they are full of very helpful people working together to solve real problems in their everyday lives.

That is awesome!

But, please, use some judgement. KevinADC is right. Just looking at some of the questions that are posted here makes it easy to spot the simple homework problems.

If nothing else, help the students, but do it in a way that makes them learn. Ask them what they have tried first. Have them post their code and output. Guide them to the correct answer instead of just handing it over.

Just my 2 cent rant for the day.
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #705
Difficulty: Medium
Confirmation bias is the tendency to search for, interpret, favor, and recall information in a way that affirms what we currently believe or think we already know.
True or False?

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Hostsfile generator

Hello I use a bash script to creating the hosts file /etc/hosts But there is a bug inside my output and I want to fix this. My Array looks like this: 205,IP 205,HOST2 unas 205,HOST1 unas15533 205,COMMENT # UNAS 775,IP ... (9 Replies)
Discussion started by: Marti95
9 Replies

2. Shell Programming and Scripting

Generator script

Hello again unix.com people, I need your help again. I'm currently need a script that will generate ip ranges... lets say from to and the output should be like this: ............. ............. (line-by-line) ... (7 Replies)
Discussion started by: galford
7 Replies

3. Shell Programming and Scripting

Sequence generator

Thanks Guys This really helped (5 Replies)
Discussion started by: robert89
5 Replies

4. Shell Programming and Scripting

time generator

Hi experts, I'd like to generate the table/file containing: number of milliseconds elapsed since midnight till midnight. It should contain 5 columns (hours minutes seconds milliseconds): Table will have theoretically 86 400 000 rows. My question is , is there somewhere the file or source... (7 Replies)
Discussion started by: hernand
7 Replies

5. What is on Your Mind?

Barcode Generator

QR Code Generator (0 Replies)
Discussion started by: Neo
0 Replies

6. Shell Programming and Scripting

print range between two patterns if it contains a pattern within the range

I want to print between the range two patterns if a particular pattern is present in between the two patterns. I am new to Unix. Any help would be greatly appreciated. e.g. Pattern1 Bombay Calcutta Delhi Pattern2 Pattern1 Patna Madras Gwalior Delhi Pattern2 Pattern1... (2 Replies)
Discussion started by: joyan321
2 Replies

7. UNIX for Dummies Questions & Answers

date generator

Is there a command to generate the unix date that is in theshadow file?>? (2 Replies)
Discussion started by: BG_JrAdmin
2 Replies

8. Cybersecurity

Password Generator

I need a great Password Generator program. I looked at a few of them, but none of them seemed to be what I wanted. So I have decided to write my own. (That's the cool thing about being a programmer....I always get what I want in software :) ) Do you have any password generators that you... (13 Replies)
Discussion started by: Perderabo
13 Replies

Featured Tech Videos