Search Results

Search: Posts Made By: MadeInGermany
215
Posted By MadeInGermany
You are right. In the post #12 I missed the other...
You are right. In the post #12 I missed the other next that skips the following 1 (always true and default print).
In fact it prints the page count after the last line. So the FNR!=NR (default print...
Forum: Shell Programming and Scripting 3 Hours Ago
215
Posted By MadeInGermany
I wonder if one should consolidate to one lengthy...
I wonder if one should consolidate to one lengthy condition?
Here is my attempt
awk -F';' '
FNR!=NR
/This is the last line of the page/ {
if (FNR==NR) total++; else printf "Page No:%d of...
Forum: UNIX for Advanced & Expert Users 22 Hours Ago
312
Posted By MadeInGermany
Actually, if the 2nd nameserver in...
Actually, if the 2nd nameserver in /etc/resolv.conf goes down, there is no impact at all, unless there is options rotate.
119
Posted By MadeInGermany
You must prune the excluded directory. -o...
You must prune the excluded directory. -o continues when not pruned.
Further, find is recursive; you may not run another recursive command in it.
find /mysite/public_html -wholename...
Forum: OS X (Apple) 1 Day Ago
233
Posted By MadeInGermany
I see. Here is how to strip leading zeros with...
I see. Here is how to strip leading zeros with Posix-shell-builtins:
num=${TEST_VAL#??}
lz=${num%%[1-9]*}
TEST_VAL=${num#$lz}
Don't know if this is really faster than expr.
Forum: OS X (Apple) 3 Days Ago
233
Posted By MadeInGermany
Better replace all expr with arithmetics by the...
Better replace all expr with arithmetics by the builtin=faster $(( ))
SEED1=$(( ${SEED1} + 1 ))
TEST_VAL=$(( 0${TEST_VAL#??} ))
312
Posted By MadeInGermany
Obviously the default timeout is too high. Add...
Obviously the default timeout is too high.
Add two lines to /etc/resolv.conf
options timeout:2
options attempts:2

These values will give a total delay of 2 * 2 = 4 seconds when the first DNS...
209
Posted By MadeInGermany
The -H is specific to GNU ps (Linux). It does...
The -H is specific to GNU ps (Linux).
It does an indentation (two spaces per hierarchy level) without any ASCII art. This is easy to post-process i.e. filter for the releavant parts.
209
Posted By MadeInGermany
Sorry, somehow my copy/paste left out a bunch of...
Sorry, somehow my copy/paste left out a bunch of lines.
Now I have corrected my original post.

--- Post updated at 11:24 ---

@nezabudka, the goal was to only show a relevant part of the...
209
Posted By MadeInGermany
[Tip] ptree for Linux
Unix (and Linux) uses a process tree that gives a natural security, by simple inheritance of attributes.

The following ptree script shows it. It runs on all Linux flavors.
Mostly useful for...
208
Posted By MadeInGermany
Yes, now you can see the respective links in the...
Yes, now you can see the respective links in the /etc/rc.d/rc?d/ directories.
First you can test your script with e.g.
service myscript stop
service myscript start
And if this works fine, do a...
208
Posted By MadeInGermany
rc.local is for compatibility with BSD Unix, not...
rc.local is for compatibility with BSD Unix, not well supported in Linux :(

In your start/stop script reate a dependency header - comments with certain keywords that belong to the LSB (Linux...
292
Posted By MadeInGermany
An not inititalized variable (or array element)...
An not inititalized variable (or array element) becomes 0 in number context, and "" in string context.
In this case, since 0 is the minimal possible string length, the 0 is perfect.

With two...
334
Posted By MadeInGermany
Add # sed '/^&@@10.10.10.10/ s/^/#/'...
Add #
sed '/^&@@10.10.10.10/ s/^/#/' /etc/rsyslog.confRemove #
sed '/^#&@@10.10.10.10/ s/^#//' /etc/rsyslog.confThe & is special in sed in the replacement string. This is avoided now.
But:
The $...
411
Posted By MadeInGermany
Can be done as a { } group. (Note: there must be...
Can be done as a { } group. (Note: there must be a semicolon or newline before the closing brace! And of cause spaces next to the [ ] { } )
if [ -f ./file2 ] && [ -f ./file3 ] && { [ -f ./file1 ]...
312
Posted By MadeInGermany
The latter suggestion is portable. Once defined...
The latter suggestion is portable.
Once defined as a function it becomes handy:
rightpad0() { printf "%s%0$((${1}-${#2}))d\n" "${2}"; }

rightpad0 9 2457
245700000
301
Posted By MadeInGermany
inotify (in Linux) is most efficient. You can...
inotify (in Linux) is most efficient.
You can also poll the file with fuser (or lsof).
file=tempfile
if [ ! -f $file ]
then
echo "$file is not present"
elif pids=$(fuser $file 2>/dev/null); [...
Forum: Linux 1 Week Ago
438
Posted By MadeInGermany
On Linux you can list your current "locale" with...
On Linux you can list your current "locale" with command
localeThe installed/available locales you can list with
locale -aThen set an appropriate locale, for example
export LC_ALL=es_ES.utf8and...
392
Posted By MadeInGermany
Or do all in bash - here is a well documented...
Or do all in bash - here is a well documented bash version:
#! /bin/bash
# bash v3 or higher

# file with list of items to find in modify_file
list_file=$1
# file for which a modified copy will...
644
Posted By MadeInGermany
You can save half of the memory by not storing in...
You can save half of the memory by not storing in arrays.
set -f # for safety: no filename generation
for i in $(cat elementen.txt)
do
for b in $(cat ITEMID.txt)
do
db2 -x "select...
630
Posted By MadeInGermany
If you have a rule like "cdc must appear at the...
If you have a rule like "cdc must appear at the beginning of the line and followed by a character",
then a simple RegularExpression does it:
perl -pe '/^cdc./ and s/^/#/' abc.txt
A -i option will...
364
Posted By MadeInGermany
The following does not work as intended: ...
The following does not work as intended:
set r=$r | tr "\n" " "
set r=$r | tr "\r" " "

set lwp=$lwp | tr "\n" " "
set lwp=$lwp | tr "\r"...
489
Posted By MadeInGermany
In awk you can strip the \r as follows awk ' ...
In awk you can strip the \r as follows
awk '
{ sub(/\r$/, "") }
...
Forum: Shell Programming and Scripting 2 Weeks Ago
414
Posted By MadeInGermany
Or sed 's/'"$TOKEN1"'\(.*\)'"$TOKEN2"'.*/\1/' ...
Or
sed 's/'"$TOKEN1"'\(.*\)'"$TOKEN2"'.*/\1/' "$INPUT1"

The point is, each $var must be within "quotes", so the shell does not do word splitting and filename generation.
Then it must be...
126
Posted By MadeInGermany
Try print instead of printf. The latter treats...
Try print instead of printf. The latter treats the first argument as a format string where % characters are special.
Showing results 1 to 25 of 500

 

Featured Tech Videos

All times are GMT -4. The time now is 07:29 AM.
Unix & Linux Forums Content Copyright 1993-2020. All Rights Reserved.
Privacy Policy