Should I learn python, ruby or perl for shell noscripting in Linux?
I just heard bash noscripting is inefficient thing to learn for shell noscripting in Linux in 2023. While being a stubborn fellow, I'd still learn bash. Which of python, perl or ruby should I learn for shell noscripting?
I'd go with anything that has tons of resources available specific to shell noscripting. I know a little bit of python already.
https://redd.it/15kat8x
@r_bash
I just heard bash noscripting is inefficient thing to learn for shell noscripting in Linux in 2023. While being a stubborn fellow, I'd still learn bash. Which of python, perl or ruby should I learn for shell noscripting?
I'd go with anything that has tons of resources available specific to shell noscripting. I know a little bit of python already.
https://redd.it/15kat8x
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
if you had to recommend only 1 bash book which one would you recommend (except tldp)
My requirements:
I don't read books line by line. I learn by solvng exercises given in the book. The exercises given in the book should have a kind of hint in the earlier chapter about it. i.e in theory.
That's all my requirement. Please recommend me a book.
I want to learn bash shell noscripting as I decided that it's not optional to learn bash as a sysadmin.
bash noscripting is mostly about sed, awk commands mastery so recommend 1 book for them as well and word processing and regular expressions in general.
https://redd.it/15kia65
@r_bash
My requirements:
I don't read books line by line. I learn by solvng exercises given in the book. The exercises given in the book should have a kind of hint in the earlier chapter about it. i.e in theory.
That's all my requirement. Please recommend me a book.
I want to learn bash shell noscripting as I decided that it's not optional to learn bash as a sysadmin.
bash noscripting is mostly about sed, awk commands mastery so recommend 1 book for them as well and word processing and regular expressions in general.
https://redd.it/15kia65
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Is there any way to change the pipe buffer size of a single specific pipe using shell tools?
I have a bash function that more-or-less does the following:
#!/bin/bash
# setup anonymopus pipe and tmpdir
exec {fd_nOrder}<><(:)
baseDir=$(mktemp -d)
# fork a coproc to print output file names to anonymous pipe (same names that `split -d` uses)
# this basically does: printf '%s\n' {00..89} {9000..9899} {990000..998999} {99900000..99989999} ...
coproc pOrder (
local v0 v9
v9=''
v0=''
printf '%s\n' {00..09} {10..89} >&${fd_nOrder}
while true; do
v9="${v9}9"
v0="${v0}0"
source <(printf '%s\n' 'printf '"'"'%s\n'"'"' {'"${v9}"'00'"${v0}"'..'"${v9}"'89'"${v9}"'} >&'"${fd_nOrder}")
done
)
# set exit trap to cleanup
trap 'kill '"${pOrder_PID}"'; exec {fd_nOrder}>&-; rm -rf "${baseDir:?}"' EXIT
# run each element of array x through someFunction in a forked process
# save output to tmpfile whose base name it read from pipe {fd_nOrder}
for kk in ${!x[@]}; do
read -r -u ${fd_nOrder}
{
someFunction "${x[$kk]}" >"${baseDir}/x${REPLY}"
} &
done
# cat all the outputs saved to ${baseDir}
# outputs will be in the same order as inputs are in array x
cat ${baseDir}/x*
# WARNING: FORKING LOOP ITERATIONS IN THE WAY SHOWN ABOVE IS DANGEROUS!!!
# Depending on how many elements are in x and how complex someFunction is
# this could easily crash your system. My "real" code does not do this.
The idea behind the above code is that the file names that I will be using to safe each forked process's output will nicely sort in order, so that I can just `cat` them and they will be ordered the same way as the inputs (in array `x`) are ordered. These are the same filenames as `split` uses when using numeric suffixes (`split -d`). They start at 00 and go up to 89, then when you hit 90 you add `00` to the end (giving 9000), then go from 9000 - 9899, when you hit 9900 add `00` to the end again (giving 900000), and keep on repeating indefinitely.
The coproc `pOrder` generates these filenames using bash's builtin shell expansion of `{#...#}` and writes them to an anonymous pipe, which is read by the main process just before it forks that iteration's `someFunction` call. It will keep generating filenames until it fills up the `{fd_nOrder}` pipe's buffer (64 kb --> ~10000 filenames initially, less as the file names keep getting longer). This has the benefit of the filenames being buffered in the pipe (so there is no wait to read them) and of not adding any additional complexity/IPC to the code (to tell pOrder when it needs to generate more filenames), but 10000 filenames is *way* more than really need to be buffered, and wastes memory and cpu time on generating filenames that will never be used.
**Is there some way (using the tools available to a shell...i.e., not with C/C++) to modify the buffer size of just the `{fd_nOrder}` pipe down to, say, 1 kb (or even less)?**
I dont want to globally change the pipe buffer size, just the buffer size for that specific pipe. Using procfs and/or sysfs is fine, though Id prefer a way that doesnt require root privileges. Using tools that are "standard" is preferable too...id rather not add any additional unusual dependencies to the code.
Thanks in advance!
***
**ADDITIONAL NOTES**
Ill again note that I dont (and you shouldnt) fork things like shown above. But, what is above makes for a simple easy-to-understand example, whereas the "actual" way I do this is more efficient and is safer and is *considerably* more complicated, so...
If you are curious, the "real" code im using this for is [here](https://github.com/jkool702/forkrun/blob/main/mySplit_nLinesAuto_test.bash), which is a prototype for a new IPC method for my [forkrun
I have a bash function that more-or-less does the following:
#!/bin/bash
# setup anonymopus pipe and tmpdir
exec {fd_nOrder}<><(:)
baseDir=$(mktemp -d)
# fork a coproc to print output file names to anonymous pipe (same names that `split -d` uses)
# this basically does: printf '%s\n' {00..89} {9000..9899} {990000..998999} {99900000..99989999} ...
coproc pOrder (
local v0 v9
v9=''
v0=''
printf '%s\n' {00..09} {10..89} >&${fd_nOrder}
while true; do
v9="${v9}9"
v0="${v0}0"
source <(printf '%s\n' 'printf '"'"'%s\n'"'"' {'"${v9}"'00'"${v0}"'..'"${v9}"'89'"${v9}"'} >&'"${fd_nOrder}")
done
)
# set exit trap to cleanup
trap 'kill '"${pOrder_PID}"'; exec {fd_nOrder}>&-; rm -rf "${baseDir:?}"' EXIT
# run each element of array x through someFunction in a forked process
# save output to tmpfile whose base name it read from pipe {fd_nOrder}
for kk in ${!x[@]}; do
read -r -u ${fd_nOrder}
{
someFunction "${x[$kk]}" >"${baseDir}/x${REPLY}"
} &
done
# cat all the outputs saved to ${baseDir}
# outputs will be in the same order as inputs are in array x
cat ${baseDir}/x*
# WARNING: FORKING LOOP ITERATIONS IN THE WAY SHOWN ABOVE IS DANGEROUS!!!
# Depending on how many elements are in x and how complex someFunction is
# this could easily crash your system. My "real" code does not do this.
The idea behind the above code is that the file names that I will be using to safe each forked process's output will nicely sort in order, so that I can just `cat` them and they will be ordered the same way as the inputs (in array `x`) are ordered. These are the same filenames as `split` uses when using numeric suffixes (`split -d`). They start at 00 and go up to 89, then when you hit 90 you add `00` to the end (giving 9000), then go from 9000 - 9899, when you hit 9900 add `00` to the end again (giving 900000), and keep on repeating indefinitely.
The coproc `pOrder` generates these filenames using bash's builtin shell expansion of `{#...#}` and writes them to an anonymous pipe, which is read by the main process just before it forks that iteration's `someFunction` call. It will keep generating filenames until it fills up the `{fd_nOrder}` pipe's buffer (64 kb --> ~10000 filenames initially, less as the file names keep getting longer). This has the benefit of the filenames being buffered in the pipe (so there is no wait to read them) and of not adding any additional complexity/IPC to the code (to tell pOrder when it needs to generate more filenames), but 10000 filenames is *way* more than really need to be buffered, and wastes memory and cpu time on generating filenames that will never be used.
**Is there some way (using the tools available to a shell...i.e., not with C/C++) to modify the buffer size of just the `{fd_nOrder}` pipe down to, say, 1 kb (or even less)?**
I dont want to globally change the pipe buffer size, just the buffer size for that specific pipe. Using procfs and/or sysfs is fine, though Id prefer a way that doesnt require root privileges. Using tools that are "standard" is preferable too...id rather not add any additional unusual dependencies to the code.
Thanks in advance!
***
**ADDITIONAL NOTES**
Ill again note that I dont (and you shouldnt) fork things like shown above. But, what is above makes for a simple easy-to-understand example, whereas the "actual" way I do this is more efficient and is safer and is *considerably* more complicated, so...
If you are curious, the "real" code im using this for is [here](https://github.com/jkool702/forkrun/blob/main/mySplit_nLinesAuto_test.bash), which is a prototype for a new IPC method for my [forkrun
GitHub
forkrun/mySplit_nLinesAuto_test.bash at main · jkool702/forkrun
runs multiple inputs through a noscript/function in parallel using bash coprocs - jkool702/forkrun
project](https://github.com/jkool702/forkrun/blob/main/forkrun.bash), which is (IMO) basically a better/faster version of `xargs` that parallelizes loops using (almost) pure bash.
Its also worth noting that I previously implemented this using a function that more or less did
getNextFileName() {
for nn in "${@}"; do
# OMITTED - SOMETHING TO DEAL WITH BASH TREATING 00-09 AS OCTALS
((nn++))
[[ ${nn} =~ ^9+0+$ ]] && nn="${nn}00"
echo ${nn}
done
}
fName='00'
for kk in ${!x[@]}; do
{
someFunction "${x[$kk]}" >"${baseDir}/x${fName}"
} &
fName="$(getNextFileName ${fName})"
done
This worked, but generating them in batches using bash's built-in expansion via `printf '%s\n' {#..#}` is *considerably* faster and more efficient.
https://redd.it/15kn6o7
@r_bash
Its also worth noting that I previously implemented this using a function that more or less did
getNextFileName() {
for nn in "${@}"; do
# OMITTED - SOMETHING TO DEAL WITH BASH TREATING 00-09 AS OCTALS
((nn++))
[[ ${nn} =~ ^9+0+$ ]] && nn="${nn}00"
echo ${nn}
done
}
fName='00'
for kk in ${!x[@]}; do
{
someFunction "${x[$kk]}" >"${baseDir}/x${fName}"
} &
fName="$(getNextFileName ${fName})"
done
This worked, but generating them in batches using bash's built-in expansion via `printf '%s\n' {#..#}` is *considerably* faster and more efficient.
https://redd.it/15kn6o7
@r_bash
GitHub
forkrun/forkrun.bash at main · jkool702/forkrun
runs multiple inputs through a noscript/function in parallel using bash coprocs - jkool702/forkrun
What is the difference between :class: and [:class:]?
I can't find anything on the net or manual.
https://redd.it/15kupef
@r_bash
I can't find anything on the net or manual.
https://redd.it/15kupef
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Small notification panel helper
After seeing another notification helper post in this sub, I felt the need to try creating one for myself. Here is the result, it uses terminal sequences to shorten the scroll area and reserve a couple of lines at the top for notification lines.
This has to be run using
I tried avoiding file-IO which is why we
The notification log is done in one
https://redd.it/15kx82h
@r_bash
After seeing another notification helper post in this sub, I felt the need to try creating one for myself. Here is the result, it uses terminal sequences to shorten the scroll area and reserve a couple of lines at the top for notification lines.
This has to be run using
source. If anyone has a better idea on how to do it without source-ing, please do let me know.I tried avoiding file-IO which is why we
source and export instead. Also I am not a fan of tput, since its syntax is more foreign to me compared to regular VT-sequences.The notification log is done in one
printf line to hopefully atomically write it's output.https://redd.it/15kx82h
@r_bash
Gist
Small bash notification panel helper
Small bash notification panel helper. GitHub Gist: instantly share code, notes, and snippets.
WSL PATH Variable Appending Duplicates After Custom Command Execution
### FALSE ALARM ###
The issue is actually because some of my own code was appending to the PATH variable essentially the same way as:
export PATH="$PATH:$PATH:/the/path/i/want"
I only found this out because I saw the post "set -x is your friend" and used it.
Sorry for wasting your guys' time with this. I'll leave the post up in case anyone wants to read it (for some reason).
(Also, I keep pressing CTRL + S when trying to save this post. I'm not sure if I'm the only one doing that or not...)
### FALSE ALARM ###
I'm having an issue with my PATH variable in WSL.
I will mention right now, I make a ton of custom functions to help me get around the WSL environment. One is called "ref" which "refreshes" my environment. This function is running exec $SHELL, that way I can source any noscripts needed without closing WSL and opening it again. It might not be secure, but It's what I use.
I'm noticing that every time I use this, paths are being appended to my PATH variable that were already there before the refresh. Because of this, bash takes forever to autocomplete a command since it has to parse 50+ paths every time.
I've already looked inside the global file in /etc/bash.bashrc, but it doesn't even reference my PATH variable, and neither does \~/.bashrc. Because I couldn't find where something could be added, I added an echo at the beginning of my \~/.bashrc file and opened a new WSL session. This is what I got as the output:
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/mnt/c/Program Files/Common Files/Oracle/Java/javapath
/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath
/mnt/c/Program Files/Microsoft/jdk-11.0.16.101-hotspot/bin
/mnt/c/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler
/mnt/c/Windows/system32
/mnt/c/Windows
/mnt/c/Windows/System32/Wbem
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/
/mnt/c/Windows/System32/OpenSSH/
/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common
/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR
/mnt/c/Program Files/dotnet/
/mnt/c/Program Files (x86)/Lua/5.1
/mnt/c/Program Files (x86)/Lua/5.1/clibs
/mnt/c/Program Files/PuTTY/
/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/
/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn/
/mnt/c/Users/%USER%/AppData/Local/Microsoft/WindowsApps
/mnt/c/Users/%USER%/AppData/Local/Programs/Microsoft VS Code/bin
/mnt/c/Users/%USER%/.dotnet/tools
/mnt/c/Users/%USER%/AppData/Local/GitHubDesktop/bin
/snap/bin
/home/%USER%/.dotnet/tools
/home/%USER%/bin
/usr/java/jdk-13.0.2/bin
This leads me to assume that bash is fetching the PATH variable from Windows and appending it to its PATH.
Does anyone know why bash is doing this and how I can fix it?
​
​
This is what my PATH looks like as of writing this:
/home/%USER%/.local/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/mnt/c/Program Files/Common Files/Oracle/Java/javapath
/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath
/mnt/c/Program Files/Microsoft/jdk-11.0.16.101-hotspot/bin
/mnt/c/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler
/mnt/c/Windows/system32
/mnt/c/Windows
/mnt/c/Windows/System32/Wbem
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/
/mnt/c/Windows/System32/OpenSSH/
/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common
/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR
/mnt/c/Program Files/dotnet/
/mnt/c/Program Files (x86)/Lua/5.1
/mnt/c/Program Files (x86)/Lua/5.1/clibs
/mnt/c/Program Files/PuTTY/
/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/
/mnt/c/Program Files/Microsoft SQL
### FALSE ALARM ###
The issue is actually because some of my own code was appending to the PATH variable essentially the same way as:
export PATH="$PATH:$PATH:/the/path/i/want"
I only found this out because I saw the post "set -x is your friend" and used it.
Sorry for wasting your guys' time with this. I'll leave the post up in case anyone wants to read it (for some reason).
(Also, I keep pressing CTRL + S when trying to save this post. I'm not sure if I'm the only one doing that or not...)
### FALSE ALARM ###
I'm having an issue with my PATH variable in WSL.
I will mention right now, I make a ton of custom functions to help me get around the WSL environment. One is called "ref" which "refreshes" my environment. This function is running exec $SHELL, that way I can source any noscripts needed without closing WSL and opening it again. It might not be secure, but It's what I use.
I'm noticing that every time I use this, paths are being appended to my PATH variable that were already there before the refresh. Because of this, bash takes forever to autocomplete a command since it has to parse 50+ paths every time.
I've already looked inside the global file in /etc/bash.bashrc, but it doesn't even reference my PATH variable, and neither does \~/.bashrc. Because I couldn't find where something could be added, I added an echo at the beginning of my \~/.bashrc file and opened a new WSL session. This is what I got as the output:
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/mnt/c/Program Files/Common Files/Oracle/Java/javapath
/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath
/mnt/c/Program Files/Microsoft/jdk-11.0.16.101-hotspot/bin
/mnt/c/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler
/mnt/c/Windows/system32
/mnt/c/Windows
/mnt/c/Windows/System32/Wbem
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/
/mnt/c/Windows/System32/OpenSSH/
/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common
/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR
/mnt/c/Program Files/dotnet/
/mnt/c/Program Files (x86)/Lua/5.1
/mnt/c/Program Files (x86)/Lua/5.1/clibs
/mnt/c/Program Files/PuTTY/
/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/
/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn/
/mnt/c/Users/%USER%/AppData/Local/Microsoft/WindowsApps
/mnt/c/Users/%USER%/AppData/Local/Programs/Microsoft VS Code/bin
/mnt/c/Users/%USER%/.dotnet/tools
/mnt/c/Users/%USER%/AppData/Local/GitHubDesktop/bin
/snap/bin
/home/%USER%/.dotnet/tools
/home/%USER%/bin
/usr/java/jdk-13.0.2/bin
This leads me to assume that bash is fetching the PATH variable from Windows and appending it to its PATH.
Does anyone know why bash is doing this and how I can fix it?
​
​
This is what my PATH looks like as of writing this:
/home/%USER%/.local/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/mnt/c/Program Files/Common Files/Oracle/Java/javapath
/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath
/mnt/c/Program Files/Microsoft/jdk-11.0.16.101-hotspot/bin
/mnt/c/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler
/mnt/c/Windows/system32
/mnt/c/Windows
/mnt/c/Windows/System32/Wbem
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/
/mnt/c/Windows/System32/OpenSSH/
/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common
/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR
/mnt/c/Program Files/dotnet/
/mnt/c/Program Files (x86)/Lua/5.1
/mnt/c/Program Files (x86)/Lua/5.1/clibs
/mnt/c/Program Files/PuTTY/
/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/
/mnt/c/Program Files/Microsoft SQL
Server/150/Tools/Binn/
/mnt/c/Users/%USER%/AppData/Local/Microsoft/WindowsApps
/mnt/c/Users/%USER%/AppData/Local/Programs/Microsoft VS Code/bin
/mnt/c/Users/%USER%/.dotnet/tools
/mnt/c/Users/%USER%/AppData/Local/GitHubDesktop/bin
/snap/bin
/home/%USER%/.dotnet/tools
/home/%USER%/bin
/usr/java/jdk-13.0.2/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/mnt/c/Program Files/Common Files/Oracle/Java/javapath
/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath
/mnt/c/Program Files/Microsoft/jdk-11.0.16.101-hotspot/bin
/mnt/c/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler
/mnt/c/Windows/system32
/mnt/c/Windows
/mnt/c/Windows/System32/Wbem
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/
/mnt/c/Windows/System32/OpenSSH/
/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common
/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR
/mnt/c/Program Files/dotnet/
/mnt/c/Program Files (x86)/Lua/5.1
/mnt/c/Program Files (x86)/Lua/5.1/clibs
/mnt/c/Program Files/PuTTY/
/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/
/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn/
/mnt/c/Users/%USER%/AppData/Local/Microsoft/WindowsApps
/mnt/c/Users/%USER%/AppData/Local/Programs/Microsoft VS Code/bin
/mnt/c/Users/%USER%/.dotnet/tools
/mnt/c/Users/%USER%/AppData/Local/GitHubDesktop/bin
/snap/bin
/home/%USER%/.dotnet/tools
/home/%USER%/bin
/usr/java/jdk-13.0.2/bin
/mnt/f/.BACKUPS/.LOADER/bin
/home/%USER%/.local/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/mnt/c/Program Files/Common Files/Oracle/Java/javapath
/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath
/mnt/c/Program Files/Microsoft/jdk-11.0.16.101-hotspot/bin
/mnt/c/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler
/mnt/c/Windows/system32
/mnt/c/Windows
/mnt/c/Windows/System32/Wbem
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/
/mnt/c/Windows/System32/OpenSSH/
/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common
/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR
/mnt/c/Program Files/dotnet/
/mnt/c/Program Files (x86)/Lua/5.1
/mnt/c/Program Files (x86)/Lua/5.1/clibs
/mnt/c/Program Files/PuTTY/
/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/
/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn/
/mnt/c/Users/%USER%/AppData/Local/Microsoft/WindowsApps
/mnt/c/Users/%USER%/AppData/Local/Programs/Microsoft VS Code/bin
/mnt/c/Users/%USER%/.dotnet/tools
/mnt/c/Users/%USER%/AppData/Local/GitHubDesktop/bin
/snap/bin
/home/%USER%/.dotnet/tools
/home/%USER%/bin
/usr/java/jdk-13.0.2/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/mnt/c/Program Files/Common Files/Oracle/Java/javapath
/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath
/mnt/c/Program Files/Microsoft/jdk-11.0.16.101-hotspot/bin
/mnt/c/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler
/mnt/c/Windows/system32
/mnt/c/Windows
/mnt/c/Windows/System32/Wbem
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/
/mnt/c/Windows/System32/OpenSSH/
/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common
/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR
/mnt/c/Program Files/dotnet/
/mnt/c/Program Files (x86)/Lua/5.1
/mnt/c/Program Files (x86)/Lua/5.1/clibs
/mnt/c/Program Files/PuTTY/
/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/
/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn/
/mnt/c/Users/%USER%/AppData/Local/Microsoft/WindowsApps
/mnt/c/Users/%USER%/AppData/Local/Programs/Microsoft VS
/mnt/c/Users/%USER%/AppData/Local/Microsoft/WindowsApps
/mnt/c/Users/%USER%/AppData/Local/Programs/Microsoft VS Code/bin
/mnt/c/Users/%USER%/.dotnet/tools
/mnt/c/Users/%USER%/AppData/Local/GitHubDesktop/bin
/snap/bin
/home/%USER%/.dotnet/tools
/home/%USER%/bin
/usr/java/jdk-13.0.2/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/mnt/c/Program Files/Common Files/Oracle/Java/javapath
/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath
/mnt/c/Program Files/Microsoft/jdk-11.0.16.101-hotspot/bin
/mnt/c/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler
/mnt/c/Windows/system32
/mnt/c/Windows
/mnt/c/Windows/System32/Wbem
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/
/mnt/c/Windows/System32/OpenSSH/
/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common
/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR
/mnt/c/Program Files/dotnet/
/mnt/c/Program Files (x86)/Lua/5.1
/mnt/c/Program Files (x86)/Lua/5.1/clibs
/mnt/c/Program Files/PuTTY/
/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/
/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn/
/mnt/c/Users/%USER%/AppData/Local/Microsoft/WindowsApps
/mnt/c/Users/%USER%/AppData/Local/Programs/Microsoft VS Code/bin
/mnt/c/Users/%USER%/.dotnet/tools
/mnt/c/Users/%USER%/AppData/Local/GitHubDesktop/bin
/snap/bin
/home/%USER%/.dotnet/tools
/home/%USER%/bin
/usr/java/jdk-13.0.2/bin
/mnt/f/.BACKUPS/.LOADER/bin
/home/%USER%/.local/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/mnt/c/Program Files/Common Files/Oracle/Java/javapath
/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath
/mnt/c/Program Files/Microsoft/jdk-11.0.16.101-hotspot/bin
/mnt/c/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler
/mnt/c/Windows/system32
/mnt/c/Windows
/mnt/c/Windows/System32/Wbem
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/
/mnt/c/Windows/System32/OpenSSH/
/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common
/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR
/mnt/c/Program Files/dotnet/
/mnt/c/Program Files (x86)/Lua/5.1
/mnt/c/Program Files (x86)/Lua/5.1/clibs
/mnt/c/Program Files/PuTTY/
/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/
/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn/
/mnt/c/Users/%USER%/AppData/Local/Microsoft/WindowsApps
/mnt/c/Users/%USER%/AppData/Local/Programs/Microsoft VS Code/bin
/mnt/c/Users/%USER%/.dotnet/tools
/mnt/c/Users/%USER%/AppData/Local/GitHubDesktop/bin
/snap/bin
/home/%USER%/.dotnet/tools
/home/%USER%/bin
/usr/java/jdk-13.0.2/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/mnt/c/Program Files/Common Files/Oracle/Java/javapath
/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath
/mnt/c/Program Files/Microsoft/jdk-11.0.16.101-hotspot/bin
/mnt/c/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler
/mnt/c/Windows/system32
/mnt/c/Windows
/mnt/c/Windows/System32/Wbem
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/
/mnt/c/Windows/System32/OpenSSH/
/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common
/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR
/mnt/c/Program Files/dotnet/
/mnt/c/Program Files (x86)/Lua/5.1
/mnt/c/Program Files (x86)/Lua/5.1/clibs
/mnt/c/Program Files/PuTTY/
/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/
/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn/
/mnt/c/Users/%USER%/AppData/Local/Microsoft/WindowsApps
/mnt/c/Users/%USER%/AppData/Local/Programs/Microsoft VS
Code/bin
/mnt/c/Users/%USER%/.dotnet/tools
/mnt/c/Users/%USER%/AppData/Local/GitHubDesktop/bin
/snap/bin
/home/%USER%/.dotnet/tools
/home/%USER%/bin
/usr/java/jdk-13.0.2/bin
/mnt/f/.BACKUPS/.LOADER/bin
/mnt/f/.BACKUPS/.LOADER/bin
​
https://redd.it/15kux9r
@r_bash
/mnt/c/Users/%USER%/.dotnet/tools
/mnt/c/Users/%USER%/AppData/Local/GitHubDesktop/bin
/snap/bin
/home/%USER%/.dotnet/tools
/home/%USER%/bin
/usr/java/jdk-13.0.2/bin
/mnt/f/.BACKUPS/.LOADER/bin
/mnt/f/.BACKUPS/.LOADER/bin
​
https://redd.it/15kux9r
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
How do I select my entire command line using the keyboard? In Windows it is ctrl + A
I'm trying to highlight my command line prompt
In Windows, I could press ctrl + A and that would select my
I tried shift + Home but it just scrolls the terminal history to the top of the page.
https://redd.it/15l23h5
@r_bash
I'm trying to highlight my command line prompt
$ cat "Random command"In Windows, I could press ctrl + A and that would select my
cat "Random command" but in Bash ctrl + A, just moves my cursor to the front of the line.I tried shift + Home but it just scrolls the terminal history to the top of the page.
https://redd.it/15l23h5
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
What happens if you just type expand with no file input?
Sorry for the basic question but it was on https://linuxjourney.com/lesson/expand-unexpand-command.
I couldn't figure out the purpose of not having a file input. It repeats what I'm entering but even if the command was converting TABs to spaces, I wasn't sure what the point would be and I'm sure there is a use case.
It doesn't even expand my variables, $city="Phoenix" doesn't do anything but repeat the input.
https://redd.it/15l8c7f
@r_bash
Sorry for the basic question but it was on https://linuxjourney.com/lesson/expand-unexpand-command.
I couldn't figure out the purpose of not having a file input. It repeats what I'm entering but even if the command was converting TABs to spaces, I wasn't sure what the point would be and I'm sure there is a use case.
It doesn't even expand my variables, $city="Phoenix" doesn't do anything but repeat the input.
https://redd.it/15l8c7f
@r_bash
How do I write a bash noscript to escape html inside a json string?
- I am trying to upload templates to Amazon SES to send html emails
- As per their documentation here they want you to upload a json file that contains html text inside a string
I wrote a cli command like this
My main problem is with the json file itself
Given an input html file and a text file, I want to generate that json on the fly and send it aws cli
Super appreciate if someone can give me directions on this. I don't even know if my approach is correct
https://redd.it/15lcr07
@r_bash
- I am trying to upload templates to Amazon SES to send html emails
- As per their documentation here they want you to upload a json file that contains html text inside a string
I wrote a cli command like this
aws ses create-template --cli-input-json file://./wiki/email-templates/ses/confirm-email.json
My main problem is with the json file itself
Given an input html file and a text file, I want to generate that json on the fly and send it aws cli
{
"Template": {
"TemplateName": "MyTemplate",
"SubjectPart": "Greetings, {{name}}!",
"HtmlPart": "WHAT TO WRITE IN BASH HERE??? to take HTML file and generate a string out of it that is valid as per JSON rules",
"TextPart": "text file to string HERE...."
}
}
Super appreciate if someone can give me directions on this. I don't even know if my approach is correct
https://redd.it/15lcr07
@r_bash
Amazon
Using templates to send personalized email with the Amazon SES API - Amazon Simple Email Service
Use the Amazon SES CreateTemplate and SendBulkEmail operations to send personalized messages.
How to move #n from the end of files name to the beginning?
I used linux before, so I know that this could be done with bash command probably.
I have a folder on my phone that has a 40 mp4 files with different names but each on of them ends with #n (#1,#2...etc)
I want to put this #n at the beginning of each file name so I can add them to a playlist on vlc as vlc doesn't support sorting by date
I will do this using termux.
And thanks in advance.
https://redd.it/15lgr8f
@r_bash
I used linux before, so I know that this could be done with bash command probably.
I have a folder on my phone that has a 40 mp4 files with different names but each on of them ends with #n (#1,#2...etc)
I want to put this #n at the beginning of each file name so I can add them to a playlist on vlc as vlc doesn't support sorting by date
I will do this using termux.
And thanks in advance.
https://redd.it/15lgr8f
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Why $(( 015 )) calculate as octal?
https://redd.it/15lm0ev
@r_bash
echo $(( 015 )) yeilds 13. Why and how to change this behavior?https://redd.it/15lm0ev
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Would like help understanding this, especially the last underscore: xargs -L 1 bash -c 'echo "$1
Hi all
So I was googling and found the following ([SOURCE-NOT-NEEDED-TO-UNDERSTAND-THE\QUESTION](https://stackoverflow.com/questions/12055198/find-out-a-git-branch-creator)):
git branch -a | xargs -L 1 bash -c 'echo "$1
It indeed works (assuming you have git, sorry I don't have a non-git example) and it can be simplified to e.g.
echo main | xargs -L 1 bash -c 'echo "$1 `git log --pretty=format:"%H %an" $1^..$1`"'
What I noticed is that if I omit the last underscore "_", it won't work. I however understand xargs which will run
Thanks!
https://redd.it/15lvnet
@r_bash
git log --pretty=format:"%H %an" $1^..$1"' Hi all
So I was googling and found the following ([SOURCE-NOT-NEEDED-TO-UNDERSTAND-THE\QUESTION](https://stackoverflow.com/questions/12055198/find-out-a-git-branch-creator)):
git branch -a | xargs -L 1 bash -c 'echo "$1
git log --pretty=format:"%H %an" $1^..$1"' It indeed works (assuming you have git, sorry I don't have a non-git example) and it can be simplified to e.g.
echo main | xargs -L 1 bash -c 'echo "$1 `git log --pretty=format:"%H %an" $1^..$1`"'
What I noticed is that if I omit the last underscore "_", it won't work. I however understand xargs which will run
bash -c on the stuff that has been piped through (e.g. git branch -a or echo main)... After that things becomes more complicated with $0 and $1... I've tried to google for understanding this syntax, but I've come to the conclusion that I don't fully understand why this command works and would like to hear if any of you can explain it, especially why the last underscore is needed...Thanks!
https://redd.it/15lvnet
@r_bash
Stack Overflow
Find out a Git branch creator
I want to find out who created a branch.
I am sort of able to do so with:
git branch -a | xargs -L 1 bash -c 'echo "$1 `git log --pretty=format:"%H %an" $1^..$1`"' _
However, this returns the last
I am sort of able to do so with:
git branch -a | xargs -L 1 bash -c 'echo "$1 `git log --pretty=format:"%H %an" $1^..$1`"' _
However, this returns the last
if else statement syntax error
I am very new to bash so the problem may be simple but my code keeps returning an error every time I run it and I've tried changing a few things but it doesn't work.
​
https://preview.redd.it/048izhufa3hb1.png?width=797&format=png&auto=webp&s=93a2b837ef7d9c93b98f82570e90763543dd7f40
​
https://redd.it/15mfu83
@r_bash
I am very new to bash so the problem may be simple but my code keeps returning an error every time I run it and I've tried changing a few things but it doesn't work.
​
https://preview.redd.it/048izhufa3hb1.png?width=797&format=png&auto=webp&s=93a2b837ef7d9c93b98f82570e90763543dd7f40
​
https://redd.it/15mfu83
@r_bash
Issues whith appending string to a variable
Edit: Solved. See below
I have a variable set by the following command:
This works correctly and gives me the output I want when I print with echo. The output is a long line that is wrapped over several lines on the screen. This becomes important later.
The issue arise when I want to append a small string to the variable
I have tried many different versions but all of them end with the same issue, where the added string is printed at the start of the last wrapping line on the display. If I resize the terminal window and run the command again, the string is again printed at the start of the last line, which is now in a different location due to the text being wrapped differently in the resized window.
I've tried running this both in bash and zsh using gnome terminal and terminator. Same result every time.
Does anyone have a clue as to what might be the cause of the issue?
EDIT: Solved by running dos2unix on the source file. The line endings were messing this up.
https://redd.it/15mgrcy
@r_bash
Edit: Solved. See below
I have a variable set by the following command:
column_names=$(head -n 1 "$filename") # | sed 's/\t/ /g')This works correctly and gives me the output I want when I print with echo. The output is a long line that is wrapped over several lines on the screen. This becomes important later.
The issue arise when I want to append a small string to the variable
" varchar(255)"I have tried many different versions but all of them end with the same issue, where the added string is printed at the start of the last wrapping line on the display. If I resize the terminal window and run the command again, the string is again printed at the start of the last line, which is now in a different location due to the text being wrapped differently in the resized window.
I've tried running this both in bash and zsh using gnome terminal and terminator. Same result every time.
Does anyone have a clue as to what might be the cause of the issue?
EDIT: Solved by running dos2unix on the source file. The line endings were messing this up.
https://redd.it/15mgrcy
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Copied large directory, want to verify, struggling with md5sum
I copied a large directory with multiple layers of folders and subfolders to a new drive and I'd like to verify that everything got copied correctly before I delete it off the old drive.
I'm trying to do this via md5sum (but open to suggestions this is just one that was mentioned a lot) but struggling. I'm not sure if it's the command that just does nothing or if it takes long because it's lots of files, but either the resulting txt file (that's meant to have the checksum) is empty or in a random order.
E.g. this command:
I've also tried this command
Any advice?
Thanks!
https://redd.it/15ml345
@r_bash
I copied a large directory with multiple layers of folders and subfolders to a new drive and I'd like to verify that everything got copied correctly before I delete it off the old drive.
I'm trying to do this via md5sum (but open to suggestions this is just one that was mentioned a lot) but struggling. I'm not sure if it's the command that just does nothing or if it takes long because it's lots of files, but either the resulting txt file (that's meant to have the checksum) is empty or in a random order.
E.g. this command:
find -type f -exec md5sum '{}' \; > md5sum.txt from here actually results in that file being created, but the checksums are then in a seemingly random order. And because of this I'm not sure if the comparison will work if it the checksums from the other drive are in a different order?I've also tried this command
find . -type f -exec md5sum {} + | LC_ALL=C sort | md5sum from here but that one just takes forever or does nothing. And because this one doesn't create a file but is meant to output a collective checksum in terminal, I don't get any feedback if anything's happening.Any advice?
Thanks!
https://redd.it/15ml345
@r_bash
Ask Ubuntu
How can I recursively list Md5sum of all the files in a directory and its subdirectories?
I want to list (and save) Md5 check sum of all the files in a directory and save that list in a text file called md5sum.txt
it would be also nice if I could
Integrate it within tree command (which
it would be also nice if I could
Integrate it within tree command (which
Real-time log streaming. Is it possible?
Can I stream the log content to a mounted partition or a remote directory?
And I have a particular environment and some applications created by the company's development team that are also very specific.
Therefore, occasionally, some problems occur due to very large logs generated in a few hours.
My idea is to stream these logs in real-time (so I can monitor them) and rotate logs daily.
Any idea how to do it with Shell Script?
https://redd.it/15mp2do
@r_bash
Can I stream the log content to a mounted partition or a remote directory?
And I have a particular environment and some applications created by the company's development team that are also very specific.
Therefore, occasionally, some problems occur due to very large logs generated in a few hours.
My idea is to stream these logs in real-time (so I can monitor them) and rotate logs daily.
Any idea how to do it with Shell Script?
https://redd.it/15mp2do
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
grep 5 numbers only?
how do i test for 5 digits only ie i tried
grep -rE "[0-9\]{5}"
​
https://redd.it/15mwp6c
@r_bash
how do i test for 5 digits only ie i tried
grep -rE "[0-9\]{5}"
​
https://redd.it/15mwp6c
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community