09-02-2008
Add a condition in your awk script to print the first line NR==1 as is and filter the rest of the lines through the commands.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
function date_diff
{
integer _dt1=$(date_to_num ${1:?})
integer _dt2=$(date_to_num ${2:?})
integer _ndt=0
if ]
then
((_ndt=_dt2-_dt1))
fi
print -- $_ndt
}
What does double dash '--' indicate ?
Can anyone please answer this (2 Replies)
Discussion started by: systemsb
2 Replies
2. UNIX for Dummies Questions & Answers
Hey guys,
I'm trying to grep for two things out of a file and I got that working but why is it randomly throwing "--" in the output? Is there a simple way to get rid of them? It only seems to do it when the line above what im looking for has numbers in it.
$ egrep -i -B 1... (3 Replies)
Discussion started by: kingdbag
3 Replies
3. Shell Programming and Scripting
I am using the fallowing script. this script seems to work fine except the file has data I do not wish to have. Is there away to omit that data. I will first provide the scrip and then a sample of the data the way it looks and then a sample of how I would like the data to look. Thanks for any... (3 Replies)
Discussion started by: krisarmstrong
3 Replies
4. Shell Programming and Scripting
Hi Unix experts;
I have 30000 files in a directory and am willing to do the following changes on each of them. The input files look like the following:
1 , 2
3 , 4
5 , 6
7 , 8
9 , 10
the output will have # in top 10 lines, insert space instead of comma. This looks like:
... (4 Replies)
Discussion started by: nxp
4 Replies
5. Shell Programming and Scripting
My files look like this
I need to remove the columns where dashes are the majority, if any of the sequences has any character in that particular position it should be removed too. The IDs and Freqs should be kept intact. Thus, the resulting file should look like this
Thanks in advance (14 Replies)
Discussion started by: Xterra
14 Replies
6. Shell Programming and Scripting
I have a file called file.txt with multiple lines in them. I'm trying to remove the first 2 characters and the last 2 with awk.
'.batman')
'.superman')
'.dragonheart')
.'superduper')
I tried doing the following and able to get rid of the first two characters. How do I remove the trailing... (5 Replies)
Discussion started by: zerofire123
5 Replies
7. Shell Programming and Scripting
Trying to use code that I found to send only new lines out of a log file by doing:
while :; do
temp=$(tail -1 logfile.out)
awk "/$last/{p=1}p" logfile.out #pipe this to log analyzer program
last="$temp"
sleep 10
done
Script works fine when logfile is basic text, but when it contains... (2 Replies)
Discussion started by: moo72moo
2 Replies
8. UNIX for Dummies Questions & Answers
I have a script to sort a list of arbitrary hosts and determine if they are supported by grepping them into a master supported list. I cut all the suffixes of the hosts in the arbitrary list, leaving the "short" hostname if you will, then grep -w them into the master list. For example:
... (1 Reply)
Discussion started by: MaindotC
1 Replies
9. Shell Programming and Scripting
Hi,
Please excuse for posting new thread on control characters,
I am facing some difficulties in removing the control character from a file extracted from top command,
i am able to see control characters using more command and in vi mode, through cat control characters are not visible ... (8 Replies)
Discussion started by: karthikram
8 Replies
10. Shell Programming and Scripting
I am trying to omit the trailer record in a variable width file
I tried using awk 'NR >1 { print prev } { prev = $0 }' filename
The above command is giving output but somehow it is trimming columns from the record. For example if my record has columns A,B,C,D
The awk gives output as A,B,C
... (4 Replies)
Discussion started by: abhilashnair
4 Replies
LEARN ABOUT DEBIAN
prunehistory
PRUNEHISTORY(8) System Manager's Manual PRUNEHISTORY(8)
NAME
prunehistory - remove file names from Usenet history file
SYNOPSIS
prunehistory [ -f filename ] [ -p ] [ input ]
DESCRIPTION
Prunehistory modifies the history(5) text file to ``remove'' a set of filenames from it. The filenames are removed by overwriting them
with spaces, so that the size and position of any following entries does not change.
Prunehistory reads the named input file, or standard input if no file is given. The input is taken as a set of lines. Blank lines and
lines starting with a number sign (``#'') are ignored. All other lines are should consist of a Message-ID followed by zero or more file-
names.
The Messge-ID is used as the dbz(3) key to get an offset into the text file. If no filenames are mentioned on the input line, then all
filenames in the text are ``removed.'' If any filenames are mentioned, they are converted into the history file notation. If they appear
in the line for the specified Message-ID then they are removed.
Since innd(8) only appends to the text file, prunehistory does not need to have any interaction with it.
OPTIONS
-p Prunehistory will normally complain about lines that do not follow the correct format. If the ``-p'' flag is used, then the program
will silently print any invalid lines on its standard output. (Blank lines and comment lines are also passed through.) This can be
useful when prunehistory is used as a filter for other programs such as reap.
-f The default name of the history file is /var/lib/news/history; to specify a different name, use the ``-f'' flag.
EXAMPLES
It is a good idea to delete purged entries and rebuild the dbz database every so often by using a script like the following:
ctlinnd throttle "Rebuilding history database"
cd /var/lib/news
awk 'NF > 2 {
printf "%s %s %s", $1, $2, $3;
for (i = 4; i <= NF; i++)
printf " %s", $i;
print "
";
}' <history >history.n
if makehistory -r -f history.n ; then
mv history.n history
mv history.n.pag history.pag
mv history.n.dir history.dir
else
echo 'Problem rebuilding history; old file not replaced'
fi
ctlinnd go "Rebuilding history database"
Note that this keeps no record of expired articles.
HISTORY
Written by Rich $alz <rsalz@uunet.uu.net> for InterNetNews. This is revision 1.9, dated 1996/10/29.
SEE ALSO
dbz(3), history(5), innd(8).
PRUNEHISTORY(8)