Visit Our UNIX and Linux User Community

Search Results

Search: Posts Made By: MadeInGermany
2,768
Posted By MadeInGermany
A shell script with only shell builtins: ...
A shell script with only shell builtins:
#!/bin/sh
set -f # unquoted $f2
IFS=";"
while IFS="," read f1 f2
do
printf "$f1, %s\n" $f2
done < file
2,820
Posted By MadeInGermany
grep -l prints the file names so you can process...
grep -l prints the file names so you can process them with xargs.
grep --include="*.org" --include="*.texi" -lir "Abstract" . | xargs headBut xargs has a problem with space characters in file names....
3,774
Posted By MadeInGermany
When read indicates an EOF and the loop ends, it...
When read indicates an EOF and the loop ends, it still has read the last incomplete line into the variable.
So you can process it after the loop.
do_dirn(){
echo "dirn :$dirn"
}
printf...
2,885
Posted By MadeInGermany
awk can do this during reading the input file -...
awk can do this during reading the input file - no need to store everything and process in the END section.
awk '$1~search {p=1} NF==0 {p=0}; p' search="NUMADDR" fileThe p variable controls when to...
1,124
Posted By MadeInGermany
crontab -l list. crontab -e edit with default...
crontab -l list.
crontab -e edit with default editor.
EDITOR=nano crontab -e edit with nano.
(crontab -l; echo '2 18 * * 0,2,4,6 find /tempr/DSC/PH[123]* \! -type d -mtime +3 -exec rm -f {} +') |...
4,839
Posted By MadeInGermany
That explains it; and your photo shows a...
That explains it; and your photo shows a non-ascii character.
It's not sufficient to sort out [a-zA-Z].

With an ERE you can ensure the input is a number:
[[ $NUM =~ ^[0-9]+$ ]] || continue
echo...
4,839
Posted By MadeInGermany
&2>/dev/null is still odd, the & is too many. The...
&2>/dev/null is still odd, the & is too many. The & before a descriptor number is needed on the RHS only, to distinguish it from a file name.
And, the only errors that a [[ ]] can produce are...
4,839
Posted By MadeInGermany
The grep args should be quoted so the shell does...
The grep args should be quoted so the shell does not try a filename generation.
builtin echo "$NUM" | $GREP -q "[a-zA-Z]" && continue
2,928
Posted By MadeInGermany
Thank you! I have never heard of the boot -F...
Thank you! I have never heard of the boot -F failsafe before.
Have read about it now: an Oracle article says it must exist as /platform/`uname -m`/failsafe.
I have access to an older Solaris 10...
3,498
Posted By MadeInGermany
I forgot that read by default omits leading space...
I forgot that read by default omits leading space (add IFS=), and mistreats a backslash (add -r).
Should be
IFS= read -r STRING << "EOT"
...
2,142
Posted By MadeInGermany
arr=("$@") Quotes around $@ (and ${arr[@]})...
arr=("$@")
Quotes around $@ (and ${arr[@]}) protect against word splitting and other substitutions, but still retain the list of argument members (and other array members).

In contrast, with $*...
3,312
Posted By MadeInGermany
Hmm, vi should actually work. But easier is ...
Hmm, vi should actually work.
But easier is
touch myfile
or
> myfile
2,785
Posted By MadeInGermany
In ksh88 (and bash) you can emulate f [[ ( $a...
In ksh88 (and bash) you can emulate
f [[ ( $a =~ sss[0-9]*$ ) ]]
with
if [[ $a == *sss* ]] && [[ ${a##*sss} != *[!0-9]* ]]
And
f [[ ( $a =~ ^sss[0-9]*$ ) ]]
with
if [[ $a == sss* ]] && [[...
1,147
Posted By MadeInGermany
Obviously it does so :( Once in Solaris...
Obviously it does so :(

Once in Solaris there was a bug that a "crontab" command wiped the crontab, even if it was aborted with Control-C.
Sun fixed it soon.

BTW, I have some scripts that...
1,147
Posted By MadeInGermany
Looks like a little bug. crontab filename...
Looks like a little bug.
crontab filename should check that filename exists and is a regular file (not a directory, device node, or other special file).

Just crontab (without arguments) should...
1,940
Posted By MadeInGermany
Is df /backup/Bckup_180320.tar &giving a...
Is
df /backup/Bckup_180320.tar &giving a result?
If it hangs hard, then there is some serious trouble. Then do further diagnostics, e.g. check mounts with
mount | grep /backupNot responding to...
1,285
Posted By MadeInGermany
The previous post is only for GNU sed that is...
The previous post is only for GNU sed that is compiled with a recent glibc that has got the \S \s from perl (PCRE (https://en.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions)).
If you want...
2,785
Posted By MadeInGermany
Of course it is [[ $string2 =~ ROS[0-9]+$ ]]...
Of course it is

[[ $string2 =~ ROS[0-9]+$ ]] && echo OK || echo NOK
Minimum one digit.
1,809
Posted By MadeInGermany
After studying the man page myself I have come to...
After studying the man page myself I have come to the conclusion that pax wants to either read files from a filesystem or write files to a filesystem or both.
So my first perception was wrong - pax...
10,525
Posted By MadeInGermany
As Scrutinizer said, %q is likely not portable. ...
As Scrutinizer said, %q is likely not portable.
And, %q solves a problem that would deserve a better solution.
The natural delimiter for piped input is a newline.
So perhaps you can use that?
Try...
10,525
Posted By MadeInGermany
Use an echo_ function...
Use an echo_ function (https://www.unix.com/shell-programming-and-scripting/283413-tip-better-echo.html?highlight=tip)
and set ECHO=echo_!
997
Posted By MadeInGermany
Do you have the command that does it (once)? ...
Do you have the command that does it (once)?
Then you can put it into crontab with an appropriate schedule.
Read about the crontab with
man crontab
1,919
Posted By MadeInGermany
Good to know. Bash was first with brace...
Good to know. Bash was first with brace expansion, now ksh and zsh are ahead. Let's see when bash will catch up again.
BTW, Bash-4 has got a number + field alignment expansion:
echo {01..10}
01 02...
2,776
Posted By MadeInGermany
Furthermore, sed gets the $line as a filename. ...
Furthermore, sed gets the $line as a filename.
If it should get it as input then do
echo "$line" | sed ...
Some shells (bash, zsh) take as well
sed ... <<< "$line"
2,776
Posted By MadeInGermany
Simply use two s commands: sed 's/.*\$\$//;...
Simply use two s commands:
sed 's/.*\$\$//; s/\..*//' test.txtIn the case there is no $$ it will still remove everything after a dot.
The following would avoid that:
sed '/.*\$\$/ { s///;...
Showing results 1 to 25 of 500

 

Featured Tech Videos

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