Search Results

Search: Posts Made By: MadeInGermany
238
Posted By MadeInGermany
I think you have ksh-88. You can augment your...
I think you have ksh-88.
You can augment your script(s) with a wrapper function (located somewhere at the beginning):
set_A(){
typeset varname=$1
shift
if [ "$BASH" ]
then
eval "$varname=(...
255
Posted By MadeInGermany
I think you expect rename -> prename as is the...
I think you expect rename -> prename as is the case on Debian. Another one with prename:
prename -n 's/^(CMRLPCR\d{6})_[^_]*/$1/' *.bumOr
prename -n 's/_[^_]*//' CMRLPCR??????_*.bum
The rename...
180
Posted By MadeInGermany
awk -F, 'a[$1]++==0' filenameis quick and dirty...
awk -F, 'a[$1]++==0' filenameis quick and dirty because it stores an unnecessary integer value.
The full and efficient code is
awk -F, '!($1 in a) { a[$1]; print }' filenameThat you can condense...
324
Posted By MadeInGermany
As I suggested, have -name "*.js?*" \! -name...
As I suggested, have -name "*.js?*" \! -name "*.jsp" or cheat with -name "*.js??*".
And most easy is of course -name "*.jsp?*".
388
Posted By MadeInGermany
%06s is obviously not portable. On different OS...
%06s is obviously not portable.
On different OS I get different results:
printf "%06s\n" 01140
01140printf "%06s\n" 01140
001140However, never this is seen as a number.

--- Post updated at...
543
Posted By MadeInGermany
2&>1 creates a file named 1 in the current...
2&>1 creates a file named 1 in the current directory.
2>&1 is correct: it redirects descriptor 2 (stderr) to descriptor 1 (stdout). The & makes the following a file descriptor.
And the following |...
360
Posted By MadeInGermany
logrotate is awful. man logrotatedoes not well...
logrotate is awful.
man logrotatedoes not well enough clarify boarder cases.
Try to add
sharedscripts
This ensures that the postrotate action occurs once.
It work as well (or even better) to...
543
Posted By MadeInGermany
You mean the extra line? I guess there is a...
You mean the extra line?
I guess there is a space character after the server3; this extra space is converted to an extra newline.
455
Posted By MadeInGermany
The ~ expands to an absolute path. If your tar is...
The ~ expands to an absolute path. If your tar is not GNU tar, then the leading / is not stripped off. And a relocation during extraction is impossible.
I would use cd and let the shell expand the...
801
Posted By MadeInGermany
That's a secret that nobody could solve in over a...
That's a secret that nobody could solve in over a decade. Why do Windows DNS servers return SERVFAIL rather than NXDOMAIN?
IMHO a severe bug. Effectively it disables the caching of an unsuccessful...
Forum: Shell Programming and Scripting 3 Weeks Ago
655
Posted By MadeInGermany
The c-shell is very primitive (and buggy). You...
The c-shell is very primitive (and buggy).
You cannot declare an array. You have to use the =( ) syntax to extend it.
Clear an array: set x=()
Append an element: set x=($x:q "last")
Prepend an...
574
Posted By MadeInGermany
If you want to look for filenames that begin with...
If you want to look for filenames that begin with the value of the i variable:
find / -type f -name "$i*" -exec ls -l {} +Within the "quotes" the shell expands $i but does not evaluate the *...
574
Posted By MadeInGermany
1. and 4. look okay. This loop method is very...
1. and 4. look okay.
This loop method is very slow: for each item it needs to scan all available files...
Turn on debug mode with set -x (turn off with set+x)
Forum: Shell Programming and Scripting 3 Weeks Ago
237
Posted By MadeInGermany
Really interesting. By definition it is a...
Really interesting. By definition it is a variable modifier that means the LHS must be a variable. Nesting can only be attempted on the RHS that is a string.
Apparently in zsh the LHS can be a...
694
Posted By MadeInGermany
I gave brief explanations as comments in the...
I gave brief explanations as comments in the code.
The following are comprehensive ones:

while condition - do - done
is a loop. The condition is the read command that reads a line from the...
694
Posted By MadeInGermany
You can store the filename in a variable and...
You can store the filename in a variable and construct the other filename from it.
In case it finds more than one filename use a for loop or while loop:
#!/bin/bash
while true
do
sleep 2400
#...
681
Posted By MadeInGermany
Regarding the version: lsb_release -a The given...
Regarding the version: lsb_release -a
The given kernel version only match for RHEL 7.7 or CentOS 7.7. Where the technical differences are neglectable.

The given grep command is one method to find...
575
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...
889
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...
765
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.
765
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...
765
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...
704
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 $...
985
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 ]...
661
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
Showing results 1 to 25 of 500

 

Featured Tech Videos

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