Search Results

Search: Posts Made By: RudiC
Forum: Shell Programming and Scripting 10 Hours Ago
87
Posted By RudiC
Try this adaption of nezabudka's proposal to...
Try this adaption of nezabudka's proposal to support both structures:
sed -n '/DISTINCT/,/quit/{s/^.*: //; p}' file, or try also

awk '/202[0-9 :,-]*/ {sub ("^.*" $9, "")} /SELECT/, /quit/' file
331
Posted By RudiC
In your first script, you're both too generous,...
In your first script, you're both too generous, and not enough, with "command substitutions". Try
for i in "${SERVICES[@]}"
do pgrep $i >/dev/null
STATS=$?
if [ $STATS == 0 ...
Forum: Shell Programming and Scripting 2 Weeks Ago
753
Posted By RudiC
I'm helpless with that little context you give....
I'm helpless with that little context you give. What's so special with those files? Does tar work without the gzip? Does it work with other files, e.g simple text files? In another directory? Without...
Forum: Shell Programming and Scripting 2 Weeks Ago
753
Posted By RudiC
I'm baffled to learn the AIX tar version doesn't...
I'm baffled to learn the AIX tar version doesn't provide the z option.


Writing the tar red output to a file (-f /backup/App_Bckup.tar) will prevent it to write to stdout, i.e. the pipe to...
Forum: Shell Programming and Scripting 2 Weeks Ago
827
Posted By RudiC
Again: too many escapes. Drop one of the two back...
Again: too many escapes. Drop one of the two back slashes in the read delimiter's -d definition. Same for ALL the escaped double quotes around file and directory names downstream.


Sure your...
260
Posted By RudiC
No surprise. If the grep "command substitution"...
No surprise. If the grep "command substitution" delivers the "empty" value, ls-l uses the default: . . man ls:

Add a certainly non-existent file name (difficult to find, as there are almost no...
Forum: Shell Programming and Scripting 2 Weeks Ago
827
Posted By RudiC
Drop the escaped double quotes in find's...
Drop the escaped double quotes in find's "starting point". find does allow multiple "starting points", BTW.
Forum: Shell Programming and Scripting 2 Weeks Ago
827
Posted By RudiC
Hmmm - I don't see...
Hmmm - I don't see /volume1/Archive/IMAGES/UPLOAD/DNG/ referenced anywhere in your script - that error msg can't come from that script. Does the DNG directory exist in the path?
263
Posted By RudiC
That space is the OFS between $1 and $2. Try like...
That space is the OFS between $1 and $2. Try like


awk '
BEGIN {for (i=split("JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC", month); i; i--) mdigit[month[i]] = i
}
{$1 =...
Forum: Shell Programming and Scripting 2 Weeks Ago
939
Posted By RudiC
I can't reproduce that specific error with the...
I can't reproduce that specific error with the script you posted. Sure you posted the correct and complete one?


Two comments:
- The #! token ("shebang") HAS to be the first two chars of a...
618
Posted By RudiC
This MAY work to identify the target files. It...
This MAY work to identify the target files. It produces an archive listing in long format including the date/time stamps, which ($4,$5) then are printed to stdout and a pipe, and, in parallel, the...
618
Posted By RudiC
I'm afraid you're out of luck. Not all tar...
I'm afraid you're out of luck. Not all tar versions provide a --delete option; e.g.

tar --version
bsdtar 2.8.4 - libarchive 2.8.4
doesn't. Those which do, like
tar --version
tar (GNU tar) 1.30...
652
Posted By RudiC
Or awk -F, ' {print $0 FS...
Or
awk -F, '
{print $0 FS substr($NF,($3=="bcd") ? 4 : 9, 1)}
' file
501
Posted By RudiC
Now, where to start? - With your syntax...
Now, where to start?


- With your syntax errors?

Beyond bash: syntax error near unexpected token `else', there are
'[' 100652 -ge 235900 ']' -a '[' 100652 -le 060000 ']'
bash: [: too many...
652
Posted By RudiC
@nezabudka: You are right if the last field is...
@nezabudka: You are right if the last field is well-formed, i.e. >= 4 chars. Compare the versions for the case of last field < 4 char...
652
Posted By RudiC
And, the .* would allow for one or more...
And, the .* would allow for one or more comma-separated fields, both in the middle as well as at line end. You might want to anchor the regex at line end, too. Proposal (untested)


sed -r...
Forum: Shell Programming and Scripting 3 Weeks Ago
1,573
Posted By RudiC
Try as given in example above # m h dom...
Try as given in example above


# m h dom mon dow user command
17 * * * * root run-parts --report /etc/cron.hourly


would yield

0 * * * * test /script_path/my_script.sh
764
Posted By RudiC
The OP specified , that's what the formatted...
The OP specified , that's what the formatted sprintf is for. As the sample data are just 10 byte long, not 12, we need to wait until resolved by the OP, we can just guess. Try this simplified but...
764
Posted By RudiC
Adapting nezabudka's proposal, (untested): ...
Adapting nezabudka's proposal, (untested):


awk '
NR==FNR {pat[$1] = $2
next
}

{$0 = substr ($0, 1, 133) sprintf ("%12s", pat[substr ($0, 134, 12)])...
665
Posted By RudiC
This is a "brace expansion". It is expanded...
This is a "brace expansion". It is expanded before any other expansions, and it cannot take any variables; read man bash very carefully:

Those strings, integers, or characters are constants, not...
771
Posted By RudiC
How about awk -F, -v"FLDS=5,8" ' BEGIN ...
How about
awk -F, -v"FLDS=5,8" '
BEGIN {FCNT = split(FLDS, FLD)
}

function CV(TMP) {Y = int(TMP/1E4)
return sprintf...
418
Posted By RudiC
First thing to do is: get rid of syntax errors...
First thing to do is: get rid of syntax errors in your code.


For your problem, try
tac file | awk '/<type>5/ {T5 = 1} /<alarmsend/ && T5 {sub (/yes/, "no"); T5 = 0} 1' | tac...
1,282
Posted By RudiC
After changing directory to "files2folders", the...
After changing directory to "files2folders", the for loop runs across all .jpg files. The "number suffixes" are extracted by means of two shell's "Parameter Expansion / Remove matching prefix...
1,282
Posted By RudiC
Start with a decent spec in the first place. ...
Start with a decent spec in the first place.


Try
cd files2folders
for FN in *.jpg
do NR="${FN%.*}"
NR="${NR#*_}"
echo mv "$FN" "$NR"*
done
mv 1244081312562_01.jpg...
Forum: Shell Programming and Scripting 4 Weeks Ago
1,942
Posted By RudiC
You were close. Try either eval echo \$$test ...
You were close. Try either
eval echo \$$test
5678
or
echo ${!test}
5678


Your approach might not be the best one. Ever thought about e.g. (associative) arrays?
Showing results 1 to 25 of 500

 

Featured Tech Videos

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