comp.unix.shell
  Home FAQ Contact Sign in
comp.unix.shell only
 
Advanced search
May 2008
motuwethfrsasuw
   1234 18
567891011 19
12131415161718 20
19202122232425 21
262728293031  22
2008
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
comp.unix.shell Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  How to calculate the difference between two timestamps?         


Author: Matthew Lincoln
Date: May 31, 2008 23:21

In a shell script I would like to calculate the difference between two timestamps.
It should look like similar to:

mystart=`date`
....
do something
....
myend=`date`
elapsed=calcdiff($mystart, $myend)
echo elapsed time=$(elapsed +%%d:%%H:%%M:%%S)

However the script above does not work.

Further question when the runtime is greater than 31 days does %%d above then contain e.g. "35"
or does it contain a value modulo 31 (here: 4) ?

Matthew
1 Comment
  What means "*/5" in crontab file?         


Author: Wolfgang Meister
Date: May 31, 2008 11:35

In the crontab I found some repetition values with a slash like

*/5

or

*/4

What does that mean e.g. in the second (=hpur) column?

Every 4 hours? Or 4 times per hour?

Wolfgang
7 Comments
  How to suppress warning messages for empty lines in shell scripts?         


Author: Jochen Berninger
Date: May 31, 2008 10:17

From the command line I called (with nohup) a shell script which contains empty lines
(for better readability).

The nohup executes the script successfully but outputs a warning for the empty line:

/usr/local/joch/bin/dotest: line 3:
: command not found

How can I suppress this warning (of cause without removing the empty line)?

Do I really have to always avoid empty lines in shell scripts?

Jochen
2 Comments
  lynx dump and awk or sed parsing         


Author: kubajs
Date: May 31, 2008 03:44

Hi,
I have problem with lynx dump output. I have following dump structure
generated from lynx -dump.

Page
[1]First link name
[2]Second link name
..
..
..
[N]Nth link name

References

1. http://link_to_first
2. http://link_to_second
...
N. http://link_to_nth
Show full article (0.86Kb)
4 Comments
  ASCII discrimination         


Author: Toshi
Date: May 30, 2008 20:27

Hi all!

I was running the following line on the UNIX terminal of my old G4 with
the latest version of Mac OS Tiger with no problem at all:

cut -f1-1 -d, fullx > ty1 ; cut -f2-2 -d, fullx > ty2 ; cut -f3-3 -d,
fullx | tr A-Z a-z > ty3

But now with THE SAME FILE, my new Mac pro with the latest Leopard, I
get the following error message:

cut: fullx: Illegal byte sequence
cut: fullx: Illegal byte sequence
cut: fullx: Illegal byte sequence

I noticed the message only occurred when a line with accented characters
(o umlaut or e acute accent) are encountered. If I replace those
characters with basic ASCII the process go as smoothly as with my old Tiger.

Is there an extra precaution I should take with my "cut" function or
some treatment I should apply to the file "fullx" for the ASCII
xenophobia to end?

Thank you!
9 Comments
  sed replace with html code and variables         


Author: bourguignon
Date: May 30, 2008 16:38

First off, I should mention that I am a sed neophyte. What little I
know I've cobbled together over the years, and each new use of it
feels like learning it over from scratch. That being said, I love the
power of it.

So, I'm trying to write a bash script that will do a replace among
several files; I've got the rest of the script down, so I simplified
it for this question (nevermind that the html doesn't work). When I
run this script, it either errors out with an "unterminated
substitution" error, or it just does nothing... Here's some code:

#!/bin/bash
NUM=4
ITEM=A001
sed s#'\<\!-- Thumb$NUM --\>'#' \\'#g
A001.html > new_A001.html

the line "" (Thumb2,3,4, etc) is in each template file
that I am running this command on...
Show full article (1.07Kb)
2 Comments
  Checking function return value in a conditional         


Author: heylow
Date: May 30, 2008 14:09

I have the following script. I am testing logical and of the return
values of the functions f and g. But I am getting the error. I am
calling the function g with two parameters t and y. Can you please
tell what I did wrong.
Thanks. Pedro

# cat funct.sh
#!/usr/bin/ksh

function f {
return 0
}

function g {
Var1=$1
Var2=$2
return 0
}

if f && "g t y"
then
echo done
fi
Show full article (0.45Kb)
5 Comments
  printing help         


Author: vakhariam
Date: May 30, 2008 09:09

#!/bin/sh

awk '{
bo = substr($0,13,3)
slm = substr($0,150,8)
slo = substr($0,175,7)
inc = substr($0,97,10)/100
busi = substr($0,83,10)
mth = substr($0,39,2)
yer = substr($0,35,4)
printf"%%3s:%%8s:%%7d:%%10.2f:%%10d:%%.2d:%%4d
\n",bo,slm,slo,inc,busi,mth,yer
}' infile | sort -t: +6 -7 +5 -6 +2 -3n +1 -2d > tmpout
Show full article (3.08Kb)
no comments
  how do I sort each text block in a file?         


Author: Markus Dehmann
Date: May 30, 2008 08:14

I have a file with several text blocks, for example a file with these
2 blocks, and I want to sort the file such that each block is sorted
(with a sort -rn):

33.2 blah
57.72 foo
100.0 bar

23.3 sdf
64.76 jzsdt

So the output should be:

100.0 bar
57.72 foo
33.2 blah

64.76 jzsdt
23.3 sdf

I have no idea how to do this on the shell. I can do it in perl, but
there the numerial sort function sort {$a <=> $b} complains if there
are also lexical elements on a line, and a shell solution might be
faster anyway. The files I want to run this on typically have several
hundreds of these blocks.
Show full article (0.64Kb)
13 Comments
  Same task on different files !         


Author: ezhil05
Date: May 30, 2008 07:51

Hi,

I am trying to write a shell program to do the same task on different
files. My file names differ by number, something like

chr1.in
chr2.in
chr3.in ... etc.

How can use, awk '{$1 = 1; print $1"\t"$2"\t"$3"\t"$4}' chr1.in >
chr1.out for all the files? I tried with sprintf in a for loop but
didn't work.

Thanks in advance.

Regards,
Ezhil
3 Comments
1 2 3 4 5 6 7 8 9