Sponsored Content
Full Discussion: whittling down a file.
Top Forums UNIX for Dummies Questions & Answers whittling down a file. Post 302166727 by MaestroRage on Tuesday 12th of February 2008 04:31:04 PM
Old 02-12-2008
I'm trying to make a list of numbers in one file, point to the respective lines in another file, and make no line repeat itself.

So File1 has numbers 1 to 5
File2 has some text, 5 lines of it.

The first line in File1 is lets say "5"

so I want to take that number, and tell unix, okay, now print out line 5 in File2.

I wanted to replace the original file because I wasn't sure how to make it traverse the list without repeating itself

And I tried using sed, because it's the only command I know which can directly print out a line of a file, no questions asked.
 

3 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match list of strings in File A and compare with File B, C and write to a output file in CSV format

Hi Friends, I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving... File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies

2. Shell Programming and Scripting

Compare 2 text file with 1 column in each file and write mismatch data to 3rd file

Hi, I need to compare 2 text files with around 60000 rows and 1 column. I need to compare these and write the mismatch data to 3rd file. File1 - file2 = file3 wc -l file1.txt 58112 wc -l file2.txt 55260 head -5 file1.txt 101214200123 101214700300 101250030067 101214100500... (10 Replies)
Discussion started by: Divya Nochiyil
10 Replies

3. Shell Programming and Scripting

Shell script (sh file) logic to compare contents of one file with another file and output to file

Shell script logic Hi I have 2 input files like with file 1 content as (file1) "BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt File 2 contents as fle(2) "BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt I want to get... (22 Replies)
Discussion started by: pottic
22 Replies
withlist(8)						      System Manager's Manual						       withlist(8)

NAME
withlist - General framework for interacting with a mailing list object. SYNOPSIS
withlist [options] listname [args ...] There are two ways to use this script: interactively or programmatically. Using it interactively allows you to play with, examine and mod- ify a MailList object from Python's interactive interpreter. When running interactively, a MailList object called `m' will be available in the global namespace. It also loads the class MailList into the global namespace. Programmatically, you can write a function to operate on a MailList object, and this script will take care of the housekeeping (see below for examples). In that case, the general usage syntax is: OPTIONS
-l, --lock Lock the list when opening. Normally the list is opened unlocked (e.g. for read-only operations). You can always lock the file after the fact by typing `m.Lock()' Note that if you use this option, you should explicitly call m.Save() before exiting, since the interpreter's clean up procedure will not automatically save changes to the MailList object (but it will unlock the list). -i, --interactive Leaves you at an interactive prompt after all other processing is complete. This is the default unless the -r option is given. -r [module.]callable, --run [module.]callable This can be used to run a script with the opened MailList object. This works by attempting to import module (which must already be accessible on your sys.path), and then calling callable from the module. callable can be a class or function; it is called with the MailList object as the first argument. If additional args are given on the command line, they are passed as subsequent positional args to the callable. Note that module. is optional; if it is omitted then a module with the name callable will be imported. The global variable `r' will be set to the results of this call. -a, --all This option only works with the -r option. Use this if you want to execute the script on all mailing lists. When you use -a you should not include a listname argument on the command line. The variable `r' will be a list of all the results. -q, --quiet Suppress all status messages. -h, --help Print a small help text and exit EXAMPLES
Here's an example of how to use the -r option. Say you have a file in the Mailman installation directory called `listaddr.py', with the following two functions: def listaddr(mlist): print mlist.GetListEmail() def requestaddr(mlist): print mlist.GetRequestEmail() Now, from the command line you can print the list's posting address by running the following from the command line: % bin/withlist -r listaddr mylist Loading list: mylist (unlocked) Importing listaddr ... Running listaddr.listaddr() ... mylist@myhost.com And you can print the list's request address by running: % bin/withlist -r listaddr.requestaddr mylist Loading list: mylist (unlocked) Importing listaddr ... Running listaddr.requestaddr() ... mylist-request@myhost.com As another example, say you wanted to change the password for a particular user on a particular list. You could put the following function in a file called `changepw.py': from Mailman.Errors import NotAMemberError def changepw(mlist, addr, newpasswd): try: mlist.setMemberPassword(addr, newpasswd) mlist.Save() except NotAMemberError: print 'No address matched:', addr and run this from the command line: % bin/withlist -l -r changepw mylist somebody@somewhere.org foobar AUTHOR
Author of Mailman is the Mailman Cabal, see http://www.list.org/ for information. This manpage is written for Debian by Bernd S. Brentrup <bsb@debian.org>. SEE ALSO
Mailman documentation on http://www.list.org/ and in /usr/share/doc/mailman. 2004-03-24 withlist(8)
All times are GMT -4. The time now is 12:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy