Sponsored Content
Top Forums Shell Programming and Scripting Fill the values between -500 to 500 -awk Post 302460227 by Klashxx on Wednesday 6th of October 2010 08:59:40 AM
Old 10-06-2010
If you want to use Python:

Code:
#!/usr/bin/python

import sys

fname=sys.argv[1]

kd={}
for line in open(fname):
    k,v = line.split()
    kd[k] = v
 
for i in range(-500,501):
    if str(i) in kd:
       print '%s %s' % (i,kd[str(i)])
    else:
       print '%s 0' % i

Usage:
Code:
script.py input:file

 

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
IDLE(1) 						      General Commands Manual							   IDLE(1)

NAME
IDLE - An Integrated DeveLopment Environment for Python SYNTAX
idle [ -dins ] [ -t title ] [ file ...] idle [ -dins ] [ -t title ] ( -c cmd | -r file ) [ arg ...] idle [ -dins ] [ -t title ] - [ arg ...] DESCRIPTION
This manual page documents briefly the idle command. This manual page was written for Debian because the original program does not have a manual page. For more information, refer to IDLE's help menu. IDLE is an Integrated DeveLopment Environment for Python. IDLE is based on Tkinter, Python's bindings to the Tk widget set. Features are 100% pure Python, multi-windows with multiple undo and Python colorizing, a Python shell window subclass, a debugger. IDLE is cross-plat- form, i.e. it works on all platforms where Tk is installed. OPTIONS
-h Print this help message and exit. -n Run IDLE without a subprocess (see Help/IDLE Help for details). The following options will override the IDLE 'settings' configuration: -e Open an edit window. -i Open a shell window. The following options imply -i and will open a shell: -c cmd Run the command in a shell, or -r file Run script from file. -d Enable the debugger. -s Run $IDLESTARTUP or $PYTHONSTARTUP before anything else. -t title Set title of shell window. A default edit window will be bypassed when -c, -r, or - are used. [arg]* and [file]* are passed to the command (-c) or script (-r) in sys.argv[1:]. EXAMPLES
idle Open an edit window or shell depending on IDLE's configuration. idle foo.py foobar.py Edit the files, also open a shell if configured to start with shell. idle -est "Baz" foo.py Run $IDLESTARTUP or $PYTHONSTARTUP, edit foo.py, and open a shell window with the title "Baz". idle -c "import sys; print sys.argv" "foo" Open a shell window and run the command, passing "-c" in sys.argv[0] and "foo" in sys.argv[1]. idle -d -s -r foo.py "Hello World" Open a shell window, run a startup script, enable the debugger, and run foo.py, passing "foo.py" in sys.argv[0] and "Hello World" in sys.argv[1]. echo "import sys; print sys.argv" | idle - "foobar" Open a shell window, run the script piped in, passing '' in sys.argv[0] and "foobar" in sys.argv[1]. SEE ALSO
python(1). AUTHORS
Various. 21 September 2004 IDLE(1)
All times are GMT -4. The time now is 01:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy