Sponsored Content
Full Discussion: GeekTool
Top Forums UNIX for Dummies Questions & Answers GeekTool Post 302189585 by era on Saturday 26th of April 2008 03:03:33 PM
Old 04-26-2008
sub does a substitution (replacement); it's basically equivalent to the sed command we discussed earlier, except you can also name an awk variable you want to perform the change on (in my case that was $3; if you leave it out, it modifies $0, i.e. the whole input line). So sub("foo", "bar", $3) will replace foo in $3 with bar. (Just the first occurrence, if there are multiple.)

Replace ":0" with just ":" before replacing ":" with "h " to get rid of any leading zero on the minutes field. (If the substitution can't be performed, it does nothing, so it's harmless to attempt it even on lines which don't have a zero.)

Last edited by era; 04-26-2008 at 04:07 PM.. Reason: Note that failed substitution is harmless
 

We Also Found This Discussion For You

1. UNIX for Dummies Questions & Answers

geekTool

Hello! Here is my problem: I try to display the uptime of my computer on my desktop with the help of a tool called GeekTool (for Mac). I want the uptime output to look like that: x day(s) y h z min (but if the pc is only running e.g for several minutes it should leave out the day and the... (1 Reply)
Discussion started by: MastaFue
1 Replies
PRINT(3)								 1								  PRINT(3)

print - Output a string

SYNOPSIS
int print (string $arg) DESCRIPTION
Outputs $arg. print is not actually a real function (it is a language construct) so you are not required to use parentheses with its argument list. PARAMETERS
o $arg - The input data. RETURN VALUES
Returns 1, always. EXAMPLES
Example #1 print examples <?php print("Hello World"); print "print() also works without parentheses."; print "This spans multiple lines. The newlines will be output as well"; print "This spans multiple lines. The newlines will be output as well."; print "escaping characters is done "Like this"."; // You can use variables inside a print statement $foo = "foobar"; $bar = "barbaz"; print "foo is $foo"; // foo is foobar // You can also use arrays $bar = array("value" => "foo"); print "this is {$bar['value']} !"; // this is foo ! // Using single quotes will print the variable name, not the value print 'foo is $foo'; // foo is $foo // If you are not using any other characters, you can just print variables print $foo; // foobar print <<<END This uses the "here document" syntax to output multiple lines with $variable interpolation. Note that the here document terminator must appear on a line with just a semicolon no extra whitespace! END; ?> NOTES
Note Because this is a language construct and not a function, it cannot be called using variable functions. SEE ALSO
echo(3), printf(3), flush(3), Heredoc syntax. PHP Documentation Group PRINT(3)
All times are GMT -4. The time now is 07:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy