Recommended solution for determining if updates are available in rhel 8
I'm working on an ansible playbook and need a way to determine if they're updates available before doing the update step. Unfortunately, i haven't found a way with the ansible yum module. Additionally, I've been messing around with 'yum check-updates' command but the results aren't 100%. Is there a way to write a boolean expression to definitively determine if any updates are available?
https://redd.it/yrwuca
@r_bash
I'm working on an ansible playbook and need a way to determine if they're updates available before doing the update step. Unfortunately, i haven't found a way with the ansible yum module. Additionally, I've been messing around with 'yum check-updates' command but the results aren't 100%. Is there a way to write a boolean expression to definitively determine if any updates are available?
https://redd.it/yrwuca
@r_bash
reddit
Recommended solution for determining if updates are available in...
I'm working on an ansible playbook and need a way to determine if they're updates available before doing the update step. Unfortunately, i haven't...
Local Variable escaping Function when it shouldn't
So I am stumped...
I am creating a couple Utility Functions as patterns to be used in a different of projects.
The first function:
ignorecase () { echo $1 | tr ':upper:' ':lower:' }
Makes any input used in it's argument, lower case. Works like a dream. Dead simple.
The second function which is depents on the first function:
SetVariableQ () {
unset "$1"; retries=0; maxretries=3
while [ $retries -lt $maxretries ]
do
clear; echo "Valid Options, yes/no: You have 3 Attempts"
retries=0
while read; do
remainattempts=$((("$maxretries") - 1 - ("$retries")))
case "$(ignorecase "$REPLY")" in
y|yes ) answer=y; break;;
n|no ) answer=n; break;;
* ) if [ "$remainattempts" != "0" ] && ([ "$answer" != "y" ] || [ "$answer" != "n" ]); then
clear; echo "Valid Options, yes/no: "$remainattempts" Attempts Remaining."; fi
if [[ "$remainattempts" == "0" ]]; then answer=n; fi
echo "'$REPLY' is an Invalid Option." >&2
if [ $((++retries)) -ge $maxretries ]; then
clear; echo "'"$1"' Variable has defaulted to 'no' due to Invalid Options Select."; break 2; fi;;
esac
done
if [ "$answer" == "y" ] || [ "$answer" == "n" ]; then break; fi
declare -g "$1"="$answer"; sleep .5; clear
done
}
Is meant to take any variable given as an argument, and then asks the user if they want that variable to be set to yes or no, then set that variable outside of the function to the users given answer.
The issue I am facing, is that the variable
Can someone please help by explain where I have messed up?
Or even better, give a tip on a solution?
https://redd.it/ys1lbo
@r_bash
So I am stumped...
I am creating a couple Utility Functions as patterns to be used in a different of projects.
The first function:
ignorecase () { echo $1 | tr ':upper:' ':lower:' }
Makes any input used in it's argument, lower case. Works like a dream. Dead simple.
The second function which is depents on the first function:
SetVariableQ () {
unset "$1"; retries=0; maxretries=3
while [ $retries -lt $maxretries ]
do
clear; echo "Valid Options, yes/no: You have 3 Attempts"
retries=0
while read; do
remainattempts=$((("$maxretries") - 1 - ("$retries")))
case "$(ignorecase "$REPLY")" in
y|yes ) answer=y; break;;
n|no ) answer=n; break;;
* ) if [ "$remainattempts" != "0" ] && ([ "$answer" != "y" ] || [ "$answer" != "n" ]); then
clear; echo "Valid Options, yes/no: "$remainattempts" Attempts Remaining."; fi
if [[ "$remainattempts" == "0" ]]; then answer=n; fi
echo "'$REPLY' is an Invalid Option." >&2
if [ $((++retries)) -ge $maxretries ]; then
clear; echo "'"$1"' Variable has defaulted to 'no' due to Invalid Options Select."; break 2; fi;;
esac
done
if [ "$answer" == "y" ] || [ "$answer" == "n" ]; then break; fi
declare -g "$1"="$answer"; sleep .5; clear
done
}
Is meant to take any variable given as an argument, and then asks the user if they want that variable to be set to yes or no, then set that variable outside of the function to the users given answer.
The issue I am facing, is that the variable
$answer that is used locally in this function to set the external variable, escapes the function. And I am at a loss as to why. Can someone please help by explain where I have messed up?
Or even better, give a tip on a solution?
https://redd.it/ys1lbo
@r_bash
reddit
Local Variable escaping Function when it shouldn't
So I am stumped... I am creating a couple Utility Functions as patterns to be used in a different of projects. The first function: ...
ltranslate: libretranslate in the terminal
Hi all! Earlier this morning I saw a post from u/Neon533 regarding his bash noscript, translate, which utilizes the Google Translate API. I thought to myself, "self, isn't there a LibreTranslate API?" And yes, yes there is.
So I wrote up an extremely similar simple bash noscript called ltranslate. It uses the German mirror of LibreTranslate. It doesn't have as many supported languages, but if you're looking for a non-Google alternative to Bash-translate, here it is.
Thanks go out to u/Neon533 for the inspiration. I know translate was a small simple noscript, but it was enough to inspire me to write this Libre version of it.
Codeberg
Github
https://redd.it/ys27f0
@r_bash
Hi all! Earlier this morning I saw a post from u/Neon533 regarding his bash noscript, translate, which utilizes the Google Translate API. I thought to myself, "self, isn't there a LibreTranslate API?" And yes, yes there is.
So I wrote up an extremely similar simple bash noscript called ltranslate. It uses the German mirror of LibreTranslate. It doesn't have as many supported languages, but if you're looking for a non-Google alternative to Bash-translate, here it is.
Thanks go out to u/Neon533 for the inspiration. I know translate was a small simple noscript, but it was enough to inspire me to write this Libre version of it.
Codeberg
Github
https://redd.it/ys27f0
@r_bash
GitHub
GitHub - mariodujic/Bash-Translate
Contribute to mariodujic/Bash-Translate development by creating an account on GitHub.
Could someone tell me why one of these works flawlessly, and the other is a buggy mess?
So, I'm going to show you two functions that are identical, save for how they get their data; one uses set variables, the other gets passed positional args. One works beautifully, the other is a buggy mess. Can anyone tell me why, though? I'm getting back into bash noscripting after a very long time (last time I noscripted bash before recently, redhat still had a consumer distribution), and this baffles me, because, to my mind, there's no real difference between the two, except for how the data is delivered to the function.
# Fonts
srcdir=".local/share/fonts"
destdir="fonts"
exportdata
exportdata() {
if ! -d $userStore/$destdir ; then
echo "Creating $userStore/$destdir"
if ! mkdir $userStore/$destdir ; then
echo "Unknown error while creating directory '$userStore/$destdir'." >&2
exit 1
fi
fi
if ! -d /home/$user/$srcdir ; then
echo "$srcdir not found. Skipping."
else
echo "Exporting $srcdir"
while true; do echo -n .; sleep 0.2; done &
trap 'kill $!' SIGTERM SIGKILL # <-- I know this doesn't work :)
if ! cp -r /home/$user/$srcdir/ $userStore/$destdir ; then
echo "Unknown error while copying file(s) from /home/$user/$srcdir to $userStore/$destdir." >&2
exit 1
fi
echo 'done'
kill $!
fi
}
# Fonts
export_data ".local/share/fonts" "fonts"
export_data() {
if [ ! -d $userStore/$2 ]; then
echo "Creating $userStore/$2"
if ! mkdir $userStore/$2 ; then
echo "Unknown error while creating directory '$userStore/$2'." >&2
exit 1
fi
fi
if [ ! -d /home/$user/$1 ]; then # <-- This part in particular doesn't work in this version
echo "$1 not found. Skipping."
else
echo "Exporting $1"
while true; do echo -n .; sleep 0.2; done &
trap 'kill $!' SIGTERM SIGKILL # <-- I know this doesn't work :)
if ! cp -r /home/$user/$1/ $userStore/$2 ; then # <-- It just tries to copy the directory that doesn't exist like the conditional wasn't even there
echo "Unknown error while copying file(s) from /home/$user/$1 to $userStore/$2." >&2
exit 1
fi
echo 'done'
kill $!
fi
}
https://redd.it/ys2elr
@r_bash
So, I'm going to show you two functions that are identical, save for how they get their data; one uses set variables, the other gets passed positional args. One works beautifully, the other is a buggy mess. Can anyone tell me why, though? I'm getting back into bash noscripting after a very long time (last time I noscripted bash before recently, redhat still had a consumer distribution), and this baffles me, because, to my mind, there's no real difference between the two, except for how the data is delivered to the function.
# Fonts
srcdir=".local/share/fonts"
destdir="fonts"
exportdata
exportdata() {
if ! -d $userStore/$destdir ; then
echo "Creating $userStore/$destdir"
if ! mkdir $userStore/$destdir ; then
echo "Unknown error while creating directory '$userStore/$destdir'." >&2
exit 1
fi
fi
if ! -d /home/$user/$srcdir ; then
echo "$srcdir not found. Skipping."
else
echo "Exporting $srcdir"
while true; do echo -n .; sleep 0.2; done &
trap 'kill $!' SIGTERM SIGKILL # <-- I know this doesn't work :)
if ! cp -r /home/$user/$srcdir/ $userStore/$destdir ; then
echo "Unknown error while copying file(s) from /home/$user/$srcdir to $userStore/$destdir." >&2
exit 1
fi
echo 'done'
kill $!
fi
}
# Fonts
export_data ".local/share/fonts" "fonts"
export_data() {
if [ ! -d $userStore/$2 ]; then
echo "Creating $userStore/$2"
if ! mkdir $userStore/$2 ; then
echo "Unknown error while creating directory '$userStore/$2'." >&2
exit 1
fi
fi
if [ ! -d /home/$user/$1 ]; then # <-- This part in particular doesn't work in this version
echo "$1 not found. Skipping."
else
echo "Exporting $1"
while true; do echo -n .; sleep 0.2; done &
trap 'kill $!' SIGTERM SIGKILL # <-- I know this doesn't work :)
if ! cp -r /home/$user/$1/ $userStore/$2 ; then # <-- It just tries to copy the directory that doesn't exist like the conditional wasn't even there
echo "Unknown error while copying file(s) from /home/$user/$1 to $userStore/$2." >&2
exit 1
fi
echo 'done'
kill $!
fi
}
https://redd.it/ys2elr
@r_bash
reddit
Could someone tell me why one of these works flawlessly, and the...
So, I'm going to show you two functions that are identical, save for how they get their data; one uses set variables, the other gets passed...
How can I get the date of latest update pf their content for a list of directories from a txt file
Hi everyone,
I listed the content of a HD with the command
Now, I have the list of the directories and the size of their content in a txt file.
I need to know for each directory how to get the date of the latest update (modif, addition... of a file) inside each of the directories.
I guess a loop
will be necessay, but how to get the information about the date?
Important informqtion (maybe): some of these subdirectories have a complex tree structure.
Can anyone help me with it?
I have been searching on the net and on furums... nothing nearing my request...
Thanks in advance
Edited: text layout
https://redd.it/ys7ied
@r_bash
Hi everyone,
I listed the content of a HD with the command
du -h --max-depth=3
Now, I have the list of the directories and the size of their content in a txt file.
I need to know for each directory how to get the date of the latest update (modif, addition... of a file) inside each of the directories.
I guess a loop
For d in file.txt
Do
Next
will be necessay, but how to get the information about the date?
Important informqtion (maybe): some of these subdirectories have a complex tree structure.
Can anyone help me with it?
I have been searching on the net and on furums... nothing nearing my request...
Thanks in advance
Edited: text layout
https://redd.it/ys7ied
@r_bash
reddit
How can I get the date of latest update pf their content for a...
Hi everyone, I listed the content of a HD with the command ``` du -h --max-depth=3 ``` Now, I have the list of the directories and the size of...
Duplicate files with the same context
Hi,
I need to use single command to create the same 20 files that all of them contain the same sentence in linux, i tried a couple of commands but non of them seem to do exactly that.
Help anyone ?
https://redd.it/ys918y
@r_bash
Hi,
I need to use single command to create the same 20 files that all of them contain the same sentence in linux, i tried a couple of commands but non of them seem to do exactly that.
Help anyone ?
https://redd.it/ys918y
@r_bash
reddit
Duplicate files with the same context
Hi, I need to use single command to create the same 20 files that all of them contain the same sentence in linux, i tried a couple of commands...
Syntax error near unexpected token 'fi'
#! /bin/bash
drawLine(){
x1=$1
y1=$2
x2=$3
y2=$4
dx=$(($x2-$x1))
dy=$(($y2-$y1))
dx1=$dx
dy1=$dy
if $dx -lt 0
then
dx1=(-$dx)
fi
if $dy -lt 0
then
dy1=(-$dy)
fi
twody1=(2$dy1)
twodx1=(2$dx1)
twody1minusdx1=$(($twody1- $dx1))
twodx1minusdy1=$(($twodx1- $dy1))
if [ $dy1 -le $dx1 ]
then
if $dx -ge 0
then
x=$x1
y=$y1
xe=$x2
else
x=$x2
y=$y2
xe=$x1
fi
echo $x
echo $y
for ((i=0; x -lt $xe; i++))
do
x=($x+1)
if $px -lt 0
then
px=$(($px + $twody1))
else
if $dx -lt 0 && $dy -lt 0
then
y=($y+1)
elif $dx -gt 0 && $dy -gt 0
then
y=($y+1)
else
y=($y-1)
fi
dy1minusdx1=$(($dy1-$dx1))
twody1minusdx1=(2*$dy1minusdx1)
px=$(($px + $twody1minusdx1))
fi
echo $x
echo $y
done
fi #(error line)
else
if $dy -ge 0
then
x=$x1
y=$y1
ye=$y2
else
x=$x2
y=$y2
ye=$y1
fi
echo $x
echo $y
for ((i=0; y<$ye;i++))
do
y=($y+1)
if $py <= 0
then
py=$(($py + $twodx1))
else
if $dx -lt 0 && $dy -lt 0
then
x=($x+1)
elif $dx -gt 0 && $dy -gt 0
then
x=($x+1)
else
x=($x-1)
fi
dx1minusdy1=$(($dx1-$dy1))
twodx1minusdy1=(2*$dx1minusdy1)
py=$(($py + $twodx1minusdy1))
fi
echo $x
echo $y
done
fi
}
drawLine 0 1 2 3
This code gives error at line 65 and i dont know why.
I am trying to make a line drawing algo for bash terminal.
and i am stuck here
please help
https://redd.it/ysggci
@r_bash
#! /bin/bash
drawLine(){
x1=$1
y1=$2
x2=$3
y2=$4
dx=$(($x2-$x1))
dy=$(($y2-$y1))
dx1=$dx
dy1=$dy
if $dx -lt 0
then
dx1=(-$dx)
fi
if $dy -lt 0
then
dy1=(-$dy)
fi
twody1=(2$dy1)
twodx1=(2$dx1)
twody1minusdx1=$(($twody1- $dx1))
twodx1minusdy1=$(($twodx1- $dy1))
if [ $dy1 -le $dx1 ]
then
if $dx -ge 0
then
x=$x1
y=$y1
xe=$x2
else
x=$x2
y=$y2
xe=$x1
fi
echo $x
echo $y
for ((i=0; x -lt $xe; i++))
do
x=($x+1)
if $px -lt 0
then
px=$(($px + $twody1))
else
if $dx -lt 0 && $dy -lt 0
then
y=($y+1)
elif $dx -gt 0 && $dy -gt 0
then
y=($y+1)
else
y=($y-1)
fi
dy1minusdx1=$(($dy1-$dx1))
twody1minusdx1=(2*$dy1minusdx1)
px=$(($px + $twody1minusdx1))
fi
echo $x
echo $y
done
fi #(error line)
else
if $dy -ge 0
then
x=$x1
y=$y1
ye=$y2
else
x=$x2
y=$y2
ye=$y1
fi
echo $x
echo $y
for ((i=0; y<$ye;i++))
do
y=($y+1)
if $py <= 0
then
py=$(($py + $twodx1))
else
if $dx -lt 0 && $dy -lt 0
then
x=($x+1)
elif $dx -gt 0 && $dy -gt 0
then
x=($x+1)
else
x=($x-1)
fi
dx1minusdy1=$(($dx1-$dy1))
twodx1minusdy1=(2*$dx1minusdy1)
py=$(($py + $twodx1minusdy1))
fi
echo $x
echo $y
done
fi
}
drawLine 0 1 2 3
This code gives error at line 65 and i dont know why.
I am trying to make a line drawing algo for bash terminal.
and i am stuck here
please help
https://redd.it/ysggci
@r_bash
reddit
Syntax error near unexpected token 'fi'
#! /bin/bash drawLine(){ x1=$1 y1=$2 x2=$3 y2=$4 dx=$(($x2-$x1)) dy=$(($y2-$y1)) ...
New to bash noscripting
I'm new to bash noscripting, but not so new that "echo 'Hello World'" is the bee's knees. I am, however, new enough that the difference between '...' and "..." is confusing. LOL. My general problem is that there's a gap between newby tutorials and advanced tutorials. Where can I find the middle level help?
Here's a noscript I've been working on:
set -x
vm_name=$(sudo virsh list --all | sed 1,2d | cut -d ' ' -f 6)
vm_dir=$(sudo virsh vol-list --pool pool | sed 1,2d | tr -s ' ' | cut -d ' ' -f 3)
vm_size=$(qemu-img info "${vm_dir[@\]}" | grep 'size' | sed -n '1,2p' | cut -d ' ' -f 1-4)
clear
echo -e "${vm_name}\\n"
echo -e "$vm_dir\\n"
for i in "${vm_size[@\]}"; do echo "$i"; done
echo "{vm_size[@\]}"
​
exit
​
​
\#vm_size () {
\# qemu-img info ${vm_dir} | ## <- here are you're problems
\# grep 'size' |
\# sed -n '1,2p' |
\# cut -d ' ' -f 1-4
\# }
I can't get output from vm_size no matter what I try. Where do I go to learn how to do the above properly?
Solutions are welcome, but resources are really what I'm looking for.
Thanks.
https://redd.it/ysf28x
@r_bash
I'm new to bash noscripting, but not so new that "echo 'Hello World'" is the bee's knees. I am, however, new enough that the difference between '...' and "..." is confusing. LOL. My general problem is that there's a gap between newby tutorials and advanced tutorials. Where can I find the middle level help?
Here's a noscript I've been working on:
set -x
vm_name=$(sudo virsh list --all | sed 1,2d | cut -d ' ' -f 6)
vm_dir=$(sudo virsh vol-list --pool pool | sed 1,2d | tr -s ' ' | cut -d ' ' -f 3)
vm_size=$(qemu-img info "${vm_dir[@\]}" | grep 'size' | sed -n '1,2p' | cut -d ' ' -f 1-4)
clear
echo -e "${vm_name}\\n"
echo -e "$vm_dir\\n"
for i in "${vm_size[@\]}"; do echo "$i"; done
echo "{vm_size[@\]}"
​
exit
​
​
\#vm_size () {
\# qemu-img info ${vm_dir} | ## <- here are you're problems
\# grep 'size' |
\# sed -n '1,2p' |
\# cut -d ' ' -f 1-4
\# }
I can't get output from vm_size no matter what I try. Where do I go to learn how to do the above properly?
Solutions are welcome, but resources are really what I'm looking for.
Thanks.
https://redd.it/ysf28x
@r_bash
reddit
New to bash noscripting
I'm new to bash noscripting, but not so new that "echo 'Hello World'" is the bee's knees. I am, however, new enough that the difference between...
Two functions, "define" and "defined?", that help you figure out whether a name has a behavior, value, executable, or definition attached to it
https://github.com/pmarreck/dotfiles/blob/master/bin/define.sh
https://redd.it/ysld5d
@r_bash
https://github.com/pmarreck/dotfiles/blob/master/bin/define.sh
https://redd.it/ysld5d
@r_bash
GitHub
dotfiles/define.sh at master · pmarreck/dotfiles
My dotfiles. Contribute to pmarreck/dotfiles development by creating an account on GitHub.
Making an alias disregard other aliases
I'm trying to rebind some dangerous commands. I keep accidentally invoking dd in the terminal, so I had the idea of aliasing "dd" to an error message, and another alias like "disk-destroyer" to the actual dd utility into. So I did this:
​
​
The problem here is that "disk-destroyer" will link back to the dd alias. Is there any way around it?
https://redd.it/ysng2m
@r_bash
I'm trying to rebind some dangerous commands. I keep accidentally invoking dd in the terminal, so I had the idea of aliasing "dd" to an error message, and another alias like "disk-destroyer" to the actual dd utility into. So I did this:
​
alias disk-destroyer='dd'alias dd="echo 'Probably the wrong command. Use alias \"disk-destroyer\" for the actual dd command.'"​
The problem here is that "disk-destroyer" will link back to the dd alias. Is there any way around it?
https://redd.it/ysng2m
@r_bash
reddit
Making an alias disregard other aliases
I'm trying to rebind some dangerous commands. I keep accidentally invoking dd in the terminal, so I had the idea of aliasing "dd" to an error...
Why won’t this bash noscript work?
https://redd.it/ysppjw
@r_bash
#! bin/bash # Printing System Variables #Print Bash shell name echo $BASH # Print Bash shell Version echo $BASH_VERSION # Print Home directory name echo $HOME *https://redd.it/ysppjw
@r_bash
reddit
Why won’t this bash noscript work?
`#! bin/bash #` `Printing System Variables #Print Bash shell name` `echo $BASH # Print Bash shell Version` `echo $BASH_VERSION # Print Home...
How can I loop through all files with file extension within a certain set of extensions?
I want to loop through all files ending in `.mp3` or `.mp4`.
I know that I can do
for f in *.{mp3,mp4}; do
However if there happen to be no mp3 files, f will also assume the value `*.mp3` which is unwanted.
​
If I only want to consider one file extension, I know that I can do
for f in *.mp3; do
[ -f "$f" ] || break
But this does not easily apply to more file extensions.
Thank you for your help!
https://redd.it/ysoiea
@r_bash
I want to loop through all files ending in `.mp3` or `.mp4`.
I know that I can do
for f in *.{mp3,mp4}; do
However if there happen to be no mp3 files, f will also assume the value `*.mp3` which is unwanted.
​
If I only want to consider one file extension, I know that I can do
for f in *.mp3; do
[ -f "$f" ] || break
But this does not easily apply to more file extensions.
Thank you for your help!
https://redd.it/ysoiea
@r_bash
reddit
How can I loop through all files with file extension within a...
I want to loop through all files ending in `.mp3` or `.mp4`. I know that I can do for f in *.{mp3,mp4}; do However if there happen to be no...
Cluster; After the job finishes ,How to initiate file transfer? WinSCP
The cluster I am working with sends emails after finishing a job.
How can I monitor email to initiate the file transfer may be it with WinSCP or through a shell noscript?
Actually, I need to have a large number of plots and calculations to be made on the go; how can I do that?
https://redd.it/ysofcb
@r_bash
The cluster I am working with sends emails after finishing a job.
How can I monitor email to initiate the file transfer may be it with WinSCP or through a shell noscript?
Actually, I need to have a large number of plots and calculations to be made on the go; how can I do that?
https://redd.it/ysofcb
@r_bash
reddit
Cluster; After the job finishes ,How to initiate file transfer? WinSCP
The cluster I am working with sends emails after finishing a job. How can I monitor email to initiate the file transfer may be it with WinSCP or...
Curl request
I have a textfile which i would like to send to my telegrambot. The issue iam facing is that the textfile does not get sorted correctly when i post it through the curl request.
But when i run it in terminal it sorts nicely without any issues.
curl -s --data text="$(cat '/files/test.txt')" --data-urlencode "chat_id=@chatid123" 'https://api.telegram.org/botmyapikey/sendMessage'
This below is the format i want. I've read about word splitting but the quotes around the cat command does not seem to make a difference.
eurusd 1621
gbpusd 1539
eurcad 1332
gbpcad 1116
nzdusd 1054
nzdcad 928
audcad 867
eurgbp 324
xauusd 133
euraud -25
audnzd -128
eurnzd -213
gbpaud -484
gbpnzd -753
usdcad -804
eurchf -840
eurjpy -856
btcusd -1186
gbpjpy -1480
cadjpy -1604
xaujpy -2432
usdjpy -3058
Help is appreciated
https://redd.it/yt5sry
@r_bash
I have a textfile which i would like to send to my telegrambot. The issue iam facing is that the textfile does not get sorted correctly when i post it through the curl request.
But when i run it in terminal it sorts nicely without any issues.
curl -s --data text="$(cat '/files/test.txt')" --data-urlencode "chat_id=@chatid123" 'https://api.telegram.org/botmyapikey/sendMessage'
This below is the format i want. I've read about word splitting but the quotes around the cat command does not seem to make a difference.
eurusd 1621
gbpusd 1539
eurcad 1332
gbpcad 1116
nzdusd 1054
nzdcad 928
audcad 867
eurgbp 324
xauusd 133
euraud -25
audnzd -128
eurnzd -213
gbpaud -484
gbpnzd -753
usdcad -804
eurchf -840
eurjpy -856
btcusd -1186
gbpjpy -1480
cadjpy -1604
xaujpy -2432
usdjpy -3058
Help is appreciated
https://redd.it/yt5sry
@r_bash
How to delete empty lines in multiple files?
I tried this but it didn't worked:
sed -i '/^$/d' *.txt
I want to be able to delete empty lines in files in subdirectories as well.
https://redd.it/ythb7w
@r_bash
I tried this but it didn't worked:
sed -i '/^$/d' *.txt
I want to be able to delete empty lines in files in subdirectories as well.
https://redd.it/ythb7w
@r_bash
reddit
How to delete empty lines in multiple files?
I tried this but it didn't worked: sed -i '/^$/d' *.txt I want to be able to delete empty lines in files in subdirectories as well.
A way to run a noscript called XYZ.sh and the output will be in a file called XYX.out
I was asked to write a noscript that a user could run and the output would be easy for them to copy.
Although this is not what the noscript did it is an example where if you run a noscript called "AScript.sh" the user will see the output and have a noscript called "AScript.out" after.
I hope someone finds the idea useful.
https://redd.it/ytm2ud
@r_bash
I was asked to write a noscript that a user could run and the output would be easy for them to copy.
Although this is not what the noscript did it is an example where if you run a noscript called "AScript.sh" the user will see the output and have a noscript called "AScript.out" after.
I hope someone finds the idea useful.
#!/usr/bin/env bash
# Get the noscript name
Me="${0##*/}"
( (
# do a read from the df command
while read -r MountPoint Type; do
# print out a command
echo "${MountPoint} uses filesystem type ${Type}"
sleep 2
# From inside the first loop do something withn the mount point
while read -r FoundFile; do
# Print out a message
echo "I have found your file \"${FoundFile}\" in filesystem \"${MountPoint}\""
done< <(find "${MountPoint}" -xdev -type f -iname "*[a-c].mp4" 2> /dev/null)
# run a df and pass it to read
done< <(df -PTh -txfs -text{3,4} | awk '!/ilesystem/ { print $7 " " $2}')
) 2>&1 ) | tee "${Me/%sh/out}"
https://redd.it/ytm2ud
@r_bash
Bash noscript to rename files excluding names in an array
I currenlty have a noscript where I rename files by removing whitespace and certain names.
prename -v 's/ /_/g' *
prename -v 's/_-_/_/g' *
prename -v 's/_\(Summer-HD\)//ig' *
prename -v 's/_\(Hammer\)//ig' *
prename -v 's/_\(Hardware-Hybrid\)//g' *
prename -v 's/_\(digital\)//ig' *
prename -v 's/_\(Resolution-SD\)//ig' *
What I have tried is a for loop and place name in an array but that has not worked.
exclude=('(Summer-HD)' '(Hammer)' '(digital)' '(Resolution-SD)' '(Vacation)' '(Hammer-Hybrid)')
for x in "${exclude[@]}";
do prename -v 's/$x/_/g' * {} \;
done
This for loop does not work at all, and I'm not sure if I can pass a variable to prename. I would like to put the names in an array since I currently have more than 200 that i would like to remove. This list will grow as I restore these files from old backups.
https://redd.it/ytqnsb
@r_bash
I currenlty have a noscript where I rename files by removing whitespace and certain names.
prename -v 's/ /_/g' *
prename -v 's/_-_/_/g' *
prename -v 's/_\(Summer-HD\)//ig' *
prename -v 's/_\(Hammer\)//ig' *
prename -v 's/_\(Hardware-Hybrid\)//g' *
prename -v 's/_\(digital\)//ig' *
prename -v 's/_\(Resolution-SD\)//ig' *
What I have tried is a for loop and place name in an array but that has not worked.
exclude=('(Summer-HD)' '(Hammer)' '(digital)' '(Resolution-SD)' '(Vacation)' '(Hammer-Hybrid)')
for x in "${exclude[@]}";
do prename -v 's/$x/_/g' * {} \;
done
This for loop does not work at all, and I'm not sure if I can pass a variable to prename. I would like to put the names in an array since I currently have more than 200 that i would like to remove. This list will grow as I restore these files from old backups.
https://redd.it/ytqnsb
@r_bash
reddit
Bash noscript to rename files excluding names in an array
I currenlty have a noscript where I rename files by removing whitespace and certain names. prename -v 's/ /_/g' * prename -v 's/_-_/_/g'...