Sponsored Content
Top Forums Shell Programming and Scripting Fill the values between -500 to 500 -awk Post 302460176 by kurumi on Wednesday 6th of October 2010 07:20:43 AM
Old 10-06-2010
Code:
#!/usr/bin/env ruby -w
# 1.9.1
h={}
File.foreach("file"){|x|a,b=x.split;h[a.to_i]=b}
(-500..500).to_a.each{|i|print (h.key?(i))?"#{i} #{h[i]}\n":"#{i} 0\n"}

Code:
 $ ruby myscript.rb


Last edited by kurumi; 10-06-2010 at 10:30 AM..
 

8 More Discussions You Might Find Interesting

1. News, Links, Events and Announcements

Linux Notebook for $500

Balance 14.1" Notebook Computer with CD-ROM Drive (2 Replies)
Discussion started by: Perderabo
2 Replies

2. Windows & DOS: Issues & Discussions

HTTP Status 500

Hello all, sori my english very bad,but 1 month i search about this case and nothing can help,maybe I wrong place but please if anybody can help me about this error: java.lang.ArrayIndexOutOfBoundsException: 0 >= 0 at java.util.Vector.elementAt(Vector.java:432) at... (2 Replies)
Discussion started by: fredginting
2 Replies

3. Shell Programming and Scripting

To add more than 500 ips

Hi, I have a server, which has more than of 1000 ip address, but only 500 ip address are responding in the Server. Here below the error message received while restarting the named Sep 22 00:25:00 ns2 named: creating IPv4 interface eth0:595 failed; interface ignored Sep 22 00:25:00 ns2... (5 Replies)
Discussion started by: gsiva
5 Replies

4. IP Networking

To add more than 500 ips

To add more than 500 ips Hi, I have a server, which has more than of 1000 ip address, but only 500 ip address are responding in the Server. Here below the error message received while restarting the named Code: Sep 22 00:25:00 ns2 named: creating IPv4 interface... (2 Replies)
Discussion started by: gsiva
2 Replies

5. UNIX Desktop Questions & Answers

for loop (001 to 500)

hey, how do i create a for loop that runs for i from 001 to 500 ? i need that the zero prefix will remain so when i print "i" it will look like so: 001 002 . . 008 009 . . 058 059 . . 500 please advise. (2 Replies)
Discussion started by: boaz733
2 Replies

6. Shell Programming and Scripting

AWK splitting a string of equal parts of 500 chars

Hi , can someone help me how to make an AWK code for splitting a string of equal parts of 500 chars in while loop? Thank you! (4 Replies)
Discussion started by: sanantonio7777
4 Replies

7. Shell Programming and Scripting

Deleting all lines except last 500

Hi All, I want to write a script which first check the line counts of a file if its more than 500 it deletes rest except the last 500.. I tried sed but it looks sed counts line numbers from the head & not from tail.. May be I need a wc -l frist then apply if statement & pass on the line count... (17 Replies)
Discussion started by: ailnilanjan
17 Replies

8. War Stories

The 500 Mile Email

Not my story, but interesting enough to be worth posting here IMHO. (Original is here) The following is the 500-mile email story in the form it originally appeared, in a post to sage-members on Sun, 24 Nov 2002.: From trey@sage.org Fri Nov 29 18:00:49 2002 Date: Sun, 24 Nov 2002 21:03:02... (3 Replies)
Discussion started by: Corona688
3 Replies
racc(1) 						      General Commands Manual							   racc(1)

NAME
racc - Ruby LALR parser generator SYNOPSIS
racc [options] file DESCRIPTION
Racc is a LALR(1) parser generator. It is written in Ruby itself, and generates Ruby program. OPTIONS
-g, --debug output parser for user level debugging. -o, --output-file <outfile> file name of output. [<fname>.tab.rb] -e, --executable <rubypath> insert #! line in output. ('ruby' to default) -E, --embedded output file which don't need runtime. -l, --no-line-convert never convert line numbers. (for ruby<=1.4.3) -c, --line-convert-all convert line numbers also header and footer. -a, --no-omit-actions never omit actions. -v, --verbose create <filename>.output file. -O, --log-file <fname> file name of verbose output. [<fname>.output] -C, --check-only syntax check only. -S, --output-status output status time to time. --no-extentions run without any ruby extentions. -h, --help print this message and quit. --version print version and quit. --runtime-version print runtime version and quit. --copyright print copyright and quit. SEE ALSO
/usr/share/doc/racc/html.en/index.html (English) or /usr/share/doc/racc/html.ja/index.html (Japanese). April 2005 racc(1)
All times are GMT -4. The time now is 01:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy