Sponsored Content
Full Discussion: whittling down a file.
Top Forums UNIX for Dummies Questions & Answers whittling down a file. Post 302166706 by MaestroRage on Tuesday 12th of February 2008 02:50:08 PM
Old 02-12-2008
whittling down a file.

I want to write a simple script which will have a list of numbers. And I want to take the first number on the list, put it into a variable, use this variable to use sed to print out a line in another document. Allow me to show you an example.

File1
5
4
3
2
1

File2
This is line 1
This is line 2
This is line 3
This is line 4
This is line 5

Script
#!/bin/sh
variable= head -1 File1
sed -n '$variable p'

(How to remove the first line from File1, and redirect the output into the same file, overwriting it. Repeat process until the file has pointed to each line on the document.

Is this... not as simple as i'm thinking? Missing out some important concepts I should be learning?

Any help is greatly appreciated.

Last edited by MaestroRage; 02-12-2008 at 04:17 PM..
 

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
CONFIG_LIST(8)						      System Manager's Manual						    CONFIG_LIST(8)

NAME
config_list - Configure a Mailman mailing list from a text file description SYNOPSIS
config_list [options] listname DESCRIPTION
This is a very powerful script which lets you view and modify a list's configuration variables from the command line. E.g. you can dump out all the list options into a plain text file (actually a valid Python file!), complete with comments explaining each variable. Or you can apply the configuration from such a file to a particular list. OPTIONS
-i filename, --inputfile=filename Configure the list by assigning each module-global variable in the file to an attribute on the list object, then saving the list. The named file is loaded with execfile() and must be legal Python code. Any variable that isn't already an attribute of the list object is ignored (a warning message is printed). See also the -c option. A special variable named `mlist' is put into the globals during the execfile, which is bound to the actual MailList object. This lets you do all manner of bizarre thing to the list object, but BEWARE! Using this can severely (and possibly irreparably) damage your mailing list! -o filename, --outputfile=filename Instead of configuring the list, print out a list's configuration variables in a format suitable for input using this script. In this way, you can easily capture the configuration settings for a particular list and imprint those settings on another list. file- name is the file to output the settings to. If filename is `-', standard out is used. -c, --checkonly The modified list is not actually changed. Only useful with -i. -v, --verbose Print the name of each attribute as it is being changed. Only useful with -i. -h, --help Print a small help text and exit NOTES
The options -o and -i are mutually exclusive. AUTHOR
Author of Mailman is the Mailman Cabal, see http://www.list.org/ for information. This manpage is written by Tollef Fog Heen <tfheen@debian.org> for Debian, but may be used by others. SEE ALSO
Mailman documentation on http://www.list.org/ and in /usr/share/doc/mailman. 2001-03-10 CONFIG_LIST(8)
All times are GMT -4. The time now is 01:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy