I seem to have gotten myself in over my head on this one. I need help combining lines together.
I have a text file containing 24,000 lines (exactly why I need awk) due to bad formatting it has separated the lines (ideally it should be 12,000 lines total).
Example of file:
... (2 Replies)
Hello I am new to shell scripting. Below are 2 scripts which I need to combine in to single script.Can some experts guide me how to proceed?
#!/bin/bash
grep "2443" /f/log/s/heduler.log | grep 2443> /tmp/memorydump
exec 6<"/tmp/memorydump"
read -u 6 data
if
then
echo "IN THEN" <... (4 Replies)
I am using:
ps -A -o command,%cpu
to get process and cpu usage figures. I want to use awk to split up the columns it returns. If I use:
awk '{print "Process: "$1"\nCPU Usage: "$NF"\n"}'
the $NF will get me the value in the last column, but if there is more than one word in the... (2 Replies)
Hi ,
Following are the two scripts :-
Script 1)
#!/bin/sh
cp file.log file.log.1
Script 2)
#!/bin/sh
diff file.log file.log.1 > DIFFERENCE.log
cp file.log file.log.1
grep "ERROR" DIFFERENCE.log
if ; then
echo "1"
else
echo "0"
fi (1 Reply)
It would be convenient to be able to combine awk tests. For example, suppose that I do this query:
awk '$1 != "Bob" || $1 != "Linda" {print $2}' datafileIs there a reasonable way to combine the conditions into a single statement? For example, in egrep, I can do:
egrep -v "Bob|Linda"... (4 Replies)
Hi readers,
I have two shell scripts running on linux machine.
Both the scripts do the following task
- Connect to DB
- Create temp files
- run select statement on table
- write the rows returned on temp file
Sample code is below
#!/bin/sh
export ORACLE_HOME=/content/oracle/10.2.0... (1 Reply)
I have a pretty simple script below:
#!/bin/sh
for i in *.cfg
do
temp=`awk '/^InputDirectory=/' ${i}`
input_dir=`echo ${temp} | awk '{ print substr( $0, 16) }'`
echo ${input_dir}
done
As you can see its opening each cfg file and searching for the line that has "InputDirectory="... (3 Replies)
i have a datafile that has several lines that look like this:
2,dataflow,Sun Mar 17 16:50:01 2013,1363539001,2990,excelsheet,660,mortar,660,4
using the following command:
awk -F, '{$3=strftime("%a %b %d %T %Y,%s",$3)}1' OFS=, $DATAFILE | egrep -v "\-OLDISSUES," | ${AWK} "/${MONTH} ${DAY}... (7 Replies)
i have a script that has many lines similar to:
echo $var | awk -F"--" '{print $2}'
as you can see, two commands are being run here. echo and awk.
id like to combine this into one awk statement.
i tried:
awk -F"--" "BEGIN{print $var; print $2}"
but i get error messages. (10 Replies)
Hi Folks,
I have two scripts that are used to start and stop services these scripts are at the location /opt/app/tre , so that start.sh internally starts the components and stop.sh internally stop all the components, now rite now if I have to stop the services then i need to go first the... (9 Replies)
Discussion started by: punpun66
9 Replies
LEARN ABOUT CENTOS
time::seconds
Time::Seconds(3pm) Perl Programmers Reference Guide Time::Seconds(3pm)NAME
Time::Seconds - a simple API to convert seconds to other date values
SYNOPSIS
use Time::Piece;
use Time::Seconds;
my $t = localtime;
$t += ONE_DAY;
my $t2 = localtime;
my $s = $t - $t2;
print "Difference is: ", $s->days, "
";
DESCRIPTION
This module is part of the Time::Piece distribution. It allows the user to find out the number of minutes, hours, days, weeks or years in a
given number of seconds. It is returned by Time::Piece when you delta two Time::Piece objects.
Time::Seconds also exports the following constants:
ONE_DAY
ONE_WEEK
ONE_HOUR
ONE_MINUTE
ONE_MONTH
ONE_YEAR
ONE_FINANCIAL_MONTH
LEAP_YEAR
NON_LEAP_YEAR
Since perl does not (yet?) support constant objects, these constants are in seconds only, so you cannot, for example, do this: "print
ONE_WEEK->minutes;"
METHODS
The following methods are available:
my $val = Time::Seconds->new(SECONDS)
$val->seconds;
$val->minutes;
$val->hours;
$val->days;
$val->weeks;
$val->months;
$val->financial_months; # 30 days
$val->years;
$val->pretty; # gives English representation of the delta
The usual arithmetic (+,-,+=,-=) is also available on the objects.
The methods make the assumption that there are 24 hours in a day, 7 days in a week, 365.24225 days in a year and 12 months in a year.
(from The Calendar FAQ at http://www.tondering.dk/claus/calendar.html)
AUTHOR
Matt Sergeant, matt@sergeant.org
Tobias Brox, tobiasb@tobiasb.funcom.com
BalieXXzs SzabieXX (dLux), dlux@kapu.hu
LICENSE
Please see Time::Piece for the license.
Bugs
Currently the methods aren't as efficient as they could be, for reasons of clarity. This is probably a bad idea.
perl v5.16.3 2013-03-04 Time::Seconds(3pm)