Terminal acts sporadic at times
If I run a command
https://redd.it/141xccx
@r_bash
If I run a command
$ while ! ping -c 1 -W 1 1.1.1.1; do echo "still waiting for 1.1.1.1" sleep 1 done and I recall it with the up arrow or I recopy and paste it, the order of the command comes up in a weird order and there is no dollar sign preceding the command like such still waiting for 1.1.1.1" sleep 1 done while ! ping -c 1 -W 1 1.1.1.1; do echo ". Also when I press backspace, it clears what I inputted but then it continues to clear what I've entered previously in "history", the backspace doesn't stop at the end of the line, it continues onto the previous lines (as if the screen is a giant txt file). I've had this issue come up in git bash as well. When I reopen my terminal this issue is resolved. It seems like a common issue and I've entered some sort of mode but I don't know how to fix it besides restarting the terminal. Any help would be appreciated.https://redd.it/141xccx
@r_bash
Reddit
r/bash on Reddit: Terminal acts sporadic at times
Posted by u/PickandRoll - No votes and 2 comments
I made a better bashmarks
So, I was trying to find a good directory bookmarking utility for terminal use, so I can cd faster and also build other noscripts around it too. I didn't find anything satisfactory. The closest thing was bashmarks, but I didn't like the way it was written and it worked. It already had done a lot of the groundwork for me and it was a good basis to start, so I decided to fork it and work from there.
And that's what I did. I also decided to make it POSIX compliant so it works with /bin/sh and dash for speed or whatever. Took me a few hours as I'm not great at shell noscripting. If anyone wants to check it out, here's the github repo.
In my opinion, which is correct, it is better than bashmarks because it doesn't hijack the possible one character aliases one might personally want to make, it also doesn't require the user to source the noscript in their bash or zsh config, and it doesn't work using environment variables like bashmarks does. It's easy to combine with a program like dmenu or fzf to choose from the list of available bookmarks as well. It also does thorough error checking, and extends the noscripts functionality. With my noscript you are able to print or delete multiple bookmarks at once, and set a new bookmark using the current working directory, or pass one as an argument.
Anyway, if you want to try a faster way to travel between commonly CDed dirs, then give it a try.
https://redd.it/142460x
@r_bash
So, I was trying to find a good directory bookmarking utility for terminal use, so I can cd faster and also build other noscripts around it too. I didn't find anything satisfactory. The closest thing was bashmarks, but I didn't like the way it was written and it worked. It already had done a lot of the groundwork for me and it was a good basis to start, so I decided to fork it and work from there.
And that's what I did. I also decided to make it POSIX compliant so it works with /bin/sh and dash for speed or whatever. Took me a few hours as I'm not great at shell noscripting. If anyone wants to check it out, here's the github repo.
In my opinion, which is correct, it is better than bashmarks because it doesn't hijack the possible one character aliases one might personally want to make, it also doesn't require the user to source the noscript in their bash or zsh config, and it doesn't work using environment variables like bashmarks does. It's easy to combine with a program like dmenu or fzf to choose from the list of available bookmarks as well. It also does thorough error checking, and extends the noscripts functionality. With my noscript you are able to print or delete multiple bookmarks at once, and set a new bookmark using the current working directory, or pass one as an argument.
Anyway, if you want to try a faster way to travel between commonly CDed dirs, then give it a try.
https://redd.it/142460x
@r_bash
GitHub
GitHub - sonjiku/shellmark: Directory bookmarks for the shell
Directory bookmarks for the shell. Contribute to sonjiku/shellmark development by creating an account on GitHub.
My bash noscript work manually, but in crontab does not work
I have this shell noscript
#!/bin/bash
userendpoints=`cat user.log |cut -d '|' -f5|jq '.request.address'|sed -e 's|upload|\nupload|g'|grep -v upload|sort |uniq`
IFS=$'\n'
echo "endpoint|count|type of response"
for i in $userendpoints
do
data=
for d in
do
echo "$i" "|"
done
done
serviceendpoints=` cat service.log |cut -d '|' -f5|jq '.request.address'|sed -e 's|compare|compare\n trunk|g' -e 's|livenessCheck|livenessCheck\n trunk|g'|grep -v trunk|sort |uniq`
for i in $serviceendpoints
do
data=
for d in
do
echo "$i" "|"
done
done
when I run this shell noscript manually it work and give me result, but when I put it in crontab I see this error and does not give us result and I see this error
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: service.log: No such file or directory
cat: service.log: No such file or directory
cat: service.log: No such file or directory
cat: service.log: No such file or directory
cat: service.log: No such file or directory
I use oracle Linux.
https://redd.it/1429m19
@r_bash
I have this shell noscript
#!/bin/bash
userendpoints=`cat user.log |cut -d '|' -f5|jq '.request.address'|sed -e 's|upload|\nupload|g'|grep -v upload|sort |uniq`
IFS=$'\n'
echo "endpoint|count|type of response"
for i in $userendpoints
do
data=
cat user.log|grep "$i"|cut -d '|' -f5|jq '.response.status'|sort|uniq -c|sed -e 's/$/|/g' -e 's/ //g' -e 's/^ //g'for d in
echo $data|tr '|' '\n'do
echo "$i" "|"
echo $d|sed -e 's/^ //'|tr -s ' ' '|'done
done
serviceendpoints=` cat service.log |cut -d '|' -f5|jq '.request.address'|sed -e 's|compare|compare\n trunk|g' -e 's|livenessCheck|livenessCheck\n trunk|g'|grep -v trunk|sort |uniq`
for i in $serviceendpoints
do
data=
cat service.log|grep "$i"|cut -d '|' -f5|jq '.response.status'|sort|uniq -c|sed -e 's/$/|/g' -e 's/ //g' -e 's/^ //g'for d in
echo $data|tr '|' '\n'do
echo "$i" "|"
echo $d|sed -e 's/^ //'|tr -s ' ' '|'done
done
when I run this shell noscript manually it work and give me result, but when I put it in crontab I see this error and does not give us result and I see this error
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: user.log: No such file or directory
cat: service.log: No such file or directory
cat: service.log: No such file or directory
cat: service.log: No such file or directory
cat: service.log: No such file or directory
cat: service.log: No such file or directory
I use oracle Linux.
https://redd.it/1429m19
@r_bash
Reddit
r/bash on Reddit: My bash noscript work manually, but in crontab does not work
Posted by u/mfaridi1978 - No votes and 1 comment
This media is not supported in your browser
VIEW IN TELEGRAM
I have developed my own Appimage package manager in full BASH, here are 3 different approuches to install the apps: xterm (1, the default one, allows to interact when prompted questions), less (2, clean but non interactive) or nothing (not clean). What is better? Have you got suggestions?
https://redd.it/142d9nx
@r_bash
https://redd.it/142d9nx
@r_bash
Add timestamp to stderr redirect
I'm running a noscript on my machine that displays a bunch of junk as it runs. I pipe that junk into /dev/null because I don't care what it says and I capture any errors in a file (I only care if the noscript doesn't run), however, the errors don't come with a time stamp. Is there a way to append a timestamp to the stderr redirect? This is the command I have, but can't figure out how to add the timestamp:
myScript.sh 2>> logfile.txt 1>/dev/null
I can't modify myScript.sh to print a date so that's not an option either. I tried something like this:
myScript.sh 2>> logfile.txt << date
but that doesn't work.
https://redd.it/142fbfs
@r_bash
I'm running a noscript on my machine that displays a bunch of junk as it runs. I pipe that junk into /dev/null because I don't care what it says and I capture any errors in a file (I only care if the noscript doesn't run), however, the errors don't come with a time stamp. Is there a way to append a timestamp to the stderr redirect? This is the command I have, but can't figure out how to add the timestamp:
myScript.sh 2>> logfile.txt 1>/dev/null
I can't modify myScript.sh to print a date so that's not an option either. I tried something like this:
myScript.sh 2>> logfile.txt << date
but that doesn't work.
https://redd.it/142fbfs
@r_bash
Reddit
r/bash on Reddit: Add timestamp to stderr redirect
Posted by u/SewerRanger - No votes and 3 comments
Temporary symlink in shell - "named process substitution" - rename a file without creating a copy/symlink on the disk?
Thunderbird doesn't open files that don't have .eml extension as email files, but instead starts to compose a new message and adds them as attachments. To use thunderbird in noscripts I'm looking for a way that would allow you to "temporarily rename" a `file` as a `file.eml`, open it in thunderbird (possibly edit, but at least read) and close it without saving anything to the disk.
While this could be achieved by either copying or creating a symlink to that file there are many elegant ways to use process substitution or here strings that instead create "temporary files" that live only for duration of the process.
Is there anything that could create such "pseudo symlinks" in bash/zsh?
https://redd.it/142srw1
@r_bash
Thunderbird doesn't open files that don't have .eml extension as email files, but instead starts to compose a new message and adds them as attachments. To use thunderbird in noscripts I'm looking for a way that would allow you to "temporarily rename" a `file` as a `file.eml`, open it in thunderbird (possibly edit, but at least read) and close it without saving anything to the disk.
While this could be achieved by either copying or creating a symlink to that file there are many elegant ways to use process substitution or here strings that instead create "temporary files" that live only for duration of the process.
Is there anything that could create such "pseudo symlinks" in bash/zsh?
https://redd.it/142srw1
@r_bash
Unix & Linux Stack Exchange
Pseudo files for temporary data
I often want to feed relatively short string data (could be several lines though) to commandline programs which accept only input from files (e.g. wdiff) in a repeated fashion. Sure I can create on...
Career Question
Sorry if this is the wrong place to post but just genuinely curious and heck there may be somewhere out there in a similar position.I currently work in tech for a large company as a tech support engineer. Its a "good" job in terms of benefits, PTO, Salary is just about six figures however I am over tech support. I have been doing some for of tech support the last 5 five years and am looking to make a pivot or at least a bigger jump in salary. My natural passion leads me to UX research/design.
I don't have a portfolio or direct UX experience yet so breaking in to that type of role is a strectch. Currently I am working on a Google UX certificate but in the interim I would like to leverage some of the skills I have gathered and increase my salary. My question is about the command line. I am pretty well versed in the Linux Bash Shell / MacOs terminal / command line as my day to day involves me scraping support logs for trouble shooting purposes.
Are there any roles, certs or career progressions you would recommend for someone in my position? I do not want to corner myself as a career long tech support engineer and would like to leverage my bash/mac os/Zsh terminal knowledge, is it possible any tips? What are some specific careers, anything tech related, that terminal/bash skills would be really helpful in? I do not necessarily expect any high paying jobs to hire me based on terminal usage alone, so obviously, you can recommended careers where I'll have to learn more. I have a few certs from Coursera, Udemy related to linux bash, Mac OS terminal as well as a VMware VCP Unified endpoint management certification. Thanks guys.
https://redd.it/14343st
@r_bash
Sorry if this is the wrong place to post but just genuinely curious and heck there may be somewhere out there in a similar position.I currently work in tech for a large company as a tech support engineer. Its a "good" job in terms of benefits, PTO, Salary is just about six figures however I am over tech support. I have been doing some for of tech support the last 5 five years and am looking to make a pivot or at least a bigger jump in salary. My natural passion leads me to UX research/design.
I don't have a portfolio or direct UX experience yet so breaking in to that type of role is a strectch. Currently I am working on a Google UX certificate but in the interim I would like to leverage some of the skills I have gathered and increase my salary. My question is about the command line. I am pretty well versed in the Linux Bash Shell / MacOs terminal / command line as my day to day involves me scraping support logs for trouble shooting purposes.
Are there any roles, certs or career progressions you would recommend for someone in my position? I do not want to corner myself as a career long tech support engineer and would like to leverage my bash/mac os/Zsh terminal knowledge, is it possible any tips? What are some specific careers, anything tech related, that terminal/bash skills would be really helpful in? I do not necessarily expect any high paying jobs to hire me based on terminal usage alone, so obviously, you can recommended careers where I'll have to learn more. I have a few certs from Coursera, Udemy related to linux bash, Mac OS terminal as well as a VMware VCP Unified endpoint management certification. Thanks guys.
https://redd.it/14343st
@r_bash
Reddit
r/bash on Reddit: Career Question
Posted by u/Tommy_Sands - No votes and no comments
Unbind ctrl+l from clearing terminal
I'm trying to unbind ctrl+l from
So far I could come up with this which is apparently not working:
https://redd.it/1439tlq
@r_bash
I'm trying to unbind ctrl+l from
clear and trying to bind Ctrl + shift + l to it.So far I could come up with this which is apparently not working:
bind -r "\C-l"
bind -x '"C-L":clear'
https://redd.it/1439tlq
@r_bash
Reddit
r/bash on Reddit: Unbind ctrl+l from clearing terminal
Posted by u/invoked_vilgax - No votes and no comments
Convert an if/else to case statement
I have this if/else chain and think it could be probably better off as a case statement but could use some pointers on evaluating the array vars.
Any tips/pointers would be much appreciated
https://redd.it/143e4y4
@r_bash
I have this if/else chain and think it could be probably better off as a case statement but could use some pointers on evaluating the array vars.
Any tips/pointers would be much appreciated
if [[ -n "${CHAIN3[0]}" ]] ;
then
printf "\t %s\n %s %s %s %s %s\n\n" \
"Evolution Chain" "${CHAIN1^}" "►" "${CHAIN2^}" "►" "${CHAIN3^}";
elif [[ -z "${CHAIN2[0]}" ]] ;
then
printf " %s\n\n" "Single Stage Evolution Pokémon";
else
printf "\t%s\n %s %s %s\n\n" \
"Evolution Chain" "${CHAIN1^}" "►" "${CHAIN2^}";
fi;
if [[ ${#CHAIN1[@]} -gt 1 ]] ;
then
printf "%s:\n" "Stage 1 Forms";
for ((i=0; i<${#CHAIN1[@]}; i++)); do
printf " %s\n" "${CHAIN1[i]}";
done;
printf "\n";
fi;
if [[ ${#CHAIN2[@]} -gt 1 ]] ;
then
printf " %s:\n" "Stage 2 Forms";
for ((i=0; i<${#CHAIN2[@]}; i++)); do
printf " %s\n" "${CHAIN2[i]}";
done;
printf "\n";
fi;
if [[ ${#CHAIN3[@]} -gt 1 ]] ;
then
printf " %s:\n" "Stage 3 Forms";
for ((i=0; i<${#CHAIN3[@]}; i++)); do
printf " %s\n" "${CHAIN3[i]}";
done;
printf "\n";
fi;
https://redd.it/143e4y4
@r_bash
Reddit
r/bash on Reddit: Convert an if/else to case statement
Posted by u/airclay - No votes and no comments
Can you remap
I recently started using tmux vim navigation, so the previous C-h mapping I had to backward kill word is not working anymore.
Clicking C-bak used to trigger the C-h mapping before. But since tmux is remapping C-h, C-bak word kill is not working anymore
https://redd.it/143d43s
@r_bash
ctrl+h and ctrl+backspace differentlyI recently started using tmux vim navigation, so the previous C-h mapping I had to backward kill word is not working anymore.
Clicking C-bak used to trigger the C-h mapping before. But since tmux is remapping C-h, C-bak word kill is not working anymore
https://redd.it/143d43s
@r_bash
Reddit
r/bash on Reddit: Can you remap `ctrl+h` and `ctrl+backspace` differently
Posted by u/invoked_vilgax - No votes and 2 comments
How to remove all <br> from all of my .html files
I have about 300 html files and on 50 of them ive unneccesarily added some <br> in some places... and now those <br> are causeing me some trouble... is there a shell noscript where i can look trough all of my files that end with .html and remove all <br> words (not the entire line, just <br>)
https://redd.it/14441a1
@r_bash
I have about 300 html files and on 50 of them ive unneccesarily added some <br> in some places... and now those <br> are causeing me some trouble... is there a shell noscript where i can look trough all of my files that end with .html and remove all <br> words (not the entire line, just <br>)
https://redd.it/14441a1
@r_bash
Reddit
r/bash on Reddit: How to remove all
from all of my .html files
from all of my .html files
Posted by u/LesCode - No votes and 1 comment
10 Unix File Management Commands That Every Developer Should Know
https://levelup.gitconnected.com/10-unix-file-management-commands-that-every-developer-should-know-afc6bdc4f27c?sk=be6fd6d1dc6cd2b32ec07bdebdf260e4
https://redd.it/1446ekg
@r_bash
https://levelup.gitconnected.com/10-unix-file-management-commands-that-every-developer-should-know-afc6bdc4f27c?sk=be6fd6d1dc6cd2b32ec07bdebdf260e4
https://redd.it/1446ekg
@r_bash
Medium
10 Unix File Management Commands That Every Developer Should Know
Use these commands in your terminal and shell noscripts to boost your programming productivity!
Here comes penis
Hi Reddit people!)
Working on my piu-piu project trying to make it to the Mars. But the journey is long so I've decided to make something quick and fun in-between... Penis mode!)
single mode
If it's not enough fun, ask a friend to join and start ~~DP~~ team play together!) Yeah it's always more fun with two barrels!)
team play
Or try to ~~cum~~ shoot each-other in duel mode. Who's got the biggest member? And most hairy balls?) Let's find it out here and now!)
duel mode
Download the game here and run it like this to enter the penis mode:
Have fun)
https://redd.it/144bxky
@r_bash
Hi Reddit people!)
Working on my piu-piu project trying to make it to the Mars. But the journey is long so I've decided to make something quick and fun in-between... Penis mode!)
single mode
If it's not enough fun, ask a friend to join and start ~~DP~~ team play together!) Yeah it's always more fun with two barrels!)
team play
Or try to ~~cum~~ shoot each-other in duel mode. Who's got the biggest member? And most hairy balls?) Let's find it out here and now!)
duel mode
Download the game here and run it like this to enter the penis mode:
penis=big ./piu-piu Have fun)
https://redd.it/144bxky
@r_bash
GitHub
GitHub - vaniacer/piu-piu-SH: This is an Old School horizontal scroller 'Shoot Them All' game in bash. With multiplayer modes team…
This is an Old School horizontal scroller 'Shoot Them All' game in bash. With multiplayer modes team and duel. You have to defeat 100 aliens to fight with Boss. I'm using ne...
Using select with command output
I have a directory that looks like this:
[\ #2] ls
2 file.mp3 6 file.mp3 9 file.mp3 13 file.mp3 20 file.mp3
1 file.mp3 5 file.mp3 16 file.mp3 12 file.mp3 19 file.mp3
8 file.mp3 4 file.mp3 15 file.mp3 11 file.mp3 18 file.mp3
7 file.mp3 3 file.mp3 14 file.mp3 10 file.mp3 17 file.mp3
I can run `select` to make a quick menu:
[\ #3] select mp3 in *mp3; do echo "$mp3"; done
1) 10 file.mp3 6) 15 file.mp3 11) 1 file.mp3 16) 5 file.mp3
2) 11 file.mp3 7) 16 file.mp3 12) 20 file.mp3 17) 6 file.mp3
3) 12 file.mp3 8) 17 file.mp3 13) 2 file.mp3 18) 7 file.mp3
4) 13 file.mp3 9) 18 file.mp3 14) 3 file.mp3 19) 8 file.mp3
5) 14 file.mp3 10) 19 file.mp3 15) 4 file.mp3 20) 9 file.mp3
#? 8
17 file.mp3
#?
What has me blocked is I can't figure out how to use a command like `ls *mp3` in the select. When I try
select mp3 in $(ls *mp3); do echo "$file"; done
I get:
1) 2 9) 6 17) 9 25) 13 33) 20
2) file.mp3 10) file.mp3 18) file.mp3 26) file.mp3 34) file.mp3
3) 1 11) 5 19) 16 27) 12 35) 19
4) file.mp3 12) file.mp3 20) file.mp3 28) file.mp3 36) file.mp3
5) 8 13) 4 21) 15 29) 11 37) 18
6) file.mp3 14) file.mp3 22) file.mp3 30) file.mp3 38) file.mp3
7) 7 15) 3 23) 14 31) 10 39) 17
8) file.mp3 16) file.mp3 24) file.mp3 32) file.mp3 40) file.mp3
#? ^C
OK. I figure just stupid me not quoting the variable once again, so I quickly edit and try:
select mp3 in "$(ls *mp3)"; do echo "$file"; done
And I get:
1) 2 file.mp3
1 file.mp3
8 file.mp3
7 file.mp3
6 file.mp3
5 file.mp3
4 file.mp3
3 file.mp3
9 file.mp3
16 file.mp3
15 file.mp3
14 file.mp3
13 file.mp3
12 file.mp3
11 file.mp3
10 file.mp3
20 file.mp3
19 file.mp3
18 file.mp3
17 file.mp3
#?
which isn't correct either. I'm sure it has something to do with bash and arrays or lists or something, but I'm just banging my head against a wall here.
https://redd.it/144lwgg
@r_bash
I have a directory that looks like this:
[\ #2] ls
2 file.mp3 6 file.mp3 9 file.mp3 13 file.mp3 20 file.mp3
1 file.mp3 5 file.mp3 16 file.mp3 12 file.mp3 19 file.mp3
8 file.mp3 4 file.mp3 15 file.mp3 11 file.mp3 18 file.mp3
7 file.mp3 3 file.mp3 14 file.mp3 10 file.mp3 17 file.mp3
I can run `select` to make a quick menu:
[\ #3] select mp3 in *mp3; do echo "$mp3"; done
1) 10 file.mp3 6) 15 file.mp3 11) 1 file.mp3 16) 5 file.mp3
2) 11 file.mp3 7) 16 file.mp3 12) 20 file.mp3 17) 6 file.mp3
3) 12 file.mp3 8) 17 file.mp3 13) 2 file.mp3 18) 7 file.mp3
4) 13 file.mp3 9) 18 file.mp3 14) 3 file.mp3 19) 8 file.mp3
5) 14 file.mp3 10) 19 file.mp3 15) 4 file.mp3 20) 9 file.mp3
#? 8
17 file.mp3
#?
What has me blocked is I can't figure out how to use a command like `ls *mp3` in the select. When I try
select mp3 in $(ls *mp3); do echo "$file"; done
I get:
1) 2 9) 6 17) 9 25) 13 33) 20
2) file.mp3 10) file.mp3 18) file.mp3 26) file.mp3 34) file.mp3
3) 1 11) 5 19) 16 27) 12 35) 19
4) file.mp3 12) file.mp3 20) file.mp3 28) file.mp3 36) file.mp3
5) 8 13) 4 21) 15 29) 11 37) 18
6) file.mp3 14) file.mp3 22) file.mp3 30) file.mp3 38) file.mp3
7) 7 15) 3 23) 14 31) 10 39) 17
8) file.mp3 16) file.mp3 24) file.mp3 32) file.mp3 40) file.mp3
#? ^C
OK. I figure just stupid me not quoting the variable once again, so I quickly edit and try:
select mp3 in "$(ls *mp3)"; do echo "$file"; done
And I get:
1) 2 file.mp3
1 file.mp3
8 file.mp3
7 file.mp3
6 file.mp3
5 file.mp3
4 file.mp3
3 file.mp3
9 file.mp3
16 file.mp3
15 file.mp3
14 file.mp3
13 file.mp3
12 file.mp3
11 file.mp3
10 file.mp3
20 file.mp3
19 file.mp3
18 file.mp3
17 file.mp3
#?
which isn't correct either. I'm sure it has something to do with bash and arrays or lists or something, but I'm just banging my head against a wall here.
https://redd.it/144lwgg
@r_bash
Reddit
r/bash on Reddit: Using select with command output
Posted by u/go_comatose_for_me - No votes and 1 comment
What does the second line do?
noscriptdir="$(dirname "$0")"
noscriptdir="$(cd "$noscriptdir" && pwd)"
First line sets the variable to the directory the noscript is in. Second line...does it again in a different way? What does this do and when would it matter?
https://redd.it/144wyog
@r_bash
noscriptdir="$(dirname "$0")"
noscriptdir="$(cd "$noscriptdir" && pwd)"
First line sets the variable to the directory the noscript is in. Second line...does it again in a different way? What does this do and when would it matter?
https://redd.it/144wyog
@r_bash
Reddit
r/bash on Reddit: What does the second line do?
Posted by u/s1eve_mcdichae1 - No votes and no comments
Need help using a text file as input for case selection.
I have the data I need gathered from df of available drives (data is exactly the same as the output for a df query just sorted and individually placed into arrays for comparisons, and a $(printf '\t')between each of the elements) and all the data sorted into arrays. I have the data of each drive going into a text file, one drive, all data, per line. What I'm wanting to do is use this text file within a case statement to choose which to do an rsync to that particular chosen drive, and I will add one additional statement to sync to all drives that have the capacity to hold the data (which is why I needed the comparison ability).
I just can't figure out how to read the file into the case and use that as the array for the menu selection to choose the drive to rsync to.
I will use this information to forward data to the rsync command if I can just figure out how to use this text file to construct the case statement itself for the menu. Thanks
https://redd.it/145b9fa
@r_bash
I have the data I need gathered from df of available drives (data is exactly the same as the output for a df query just sorted and individually placed into arrays for comparisons, and a $(printf '\t')between each of the elements) and all the data sorted into arrays. I have the data of each drive going into a text file, one drive, all data, per line. What I'm wanting to do is use this text file within a case statement to choose which to do an rsync to that particular chosen drive, and I will add one additional statement to sync to all drives that have the capacity to hold the data (which is why I needed the comparison ability).
I just can't figure out how to read the file into the case and use that as the array for the menu selection to choose the drive to rsync to.
I will use this information to forward data to the rsync command if I can just figure out how to use this text file to construct the case statement itself for the menu. Thanks
https://redd.it/145b9fa
@r_bash
Reddit
r/bash on Reddit: Need help using a text file as input for case selection.
Posted by u/RedHeadHippy666 - No votes and 2 comments
r/bash will go dark from 12-14 June in protest against Reddit API price changes
Dear r/bash users,
As most of you have already heard by now, Reddit’s new API price changes will have a severe detrimental impact on third-party apps, essentially forcing them to shut down. If you use a third-party app to browse Reddit, you will no longer be able to do so starting 1st July.
Furthermore, because Reddit’s native app is not designed to accommodate people with visual impairements, starting 1st July they will be forced to either quit using Reddit altogether, or switch to Old Reddit on desktop, which might eventually face shutdown too.
In protest against this, we decided to join a growing list of subreddits and make r/bash private for the period of 12-14 June, meaning you will not be able to access the subreddit during this time.
https://redd.it/145esyf
@r_bash
Dear r/bash users,
As most of you have already heard by now, Reddit’s new API price changes will have a severe detrimental impact on third-party apps, essentially forcing them to shut down. If you use a third-party app to browse Reddit, you will no longer be able to do so starting 1st July.
Furthermore, because Reddit’s native app is not designed to accommodate people with visual impairements, starting 1st July they will be forced to either quit using Reddit altogether, or switch to Old Reddit on desktop, which might eventually face shutdown too.
In protest against this, we decided to join a growing list of subreddits and make r/bash private for the period of 12-14 June, meaning you will not be able to access the subreddit during this time.
https://redd.it/145esyf
@r_bash
Reddit
From the ModCoord community on Reddit
Explore this post and more from the ModCoord community
Need help with a noscript
hello friends I am currently trying to solve this "
1. if a number is divisible by 3, print "SMILE" instead of the number.
and after a few hours of trying have figured I need to ask for help if you can that would be much appreciated thanks.
https://redd.it/145sdj0
@r_bash
hello friends I am currently trying to solve this "
1. if a number is divisible by 3, print "SMILE" instead of the number.
and after a few hours of trying have figured I need to ask for help if you can that would be much appreciated thanks.
https://redd.it/145sdj0
@r_bash
Reddit
r/bash on Reddit: Need help with a noscript
Posted by u/Logunstious - No votes and 2 comments
Running weekly average
I think I may be getting way out of my ability here. If I have a file that looks like this:
data.txt:
Day Data
1 29
2 37
3 20
4 24
5 33
6 29
7 11
8 40
9 31
10 36
11 15
12 41
13 47
14 17
15 46
16 16
17 37
18 21
19 39
20 12
21 44
22 35
23 20
24 26
25 41
26 13
27 41
28 14
29 20
30 47
I would like to add a running average of the previous 5 days. So that given the data file, I would output:
Day Data Running 5 day average
1 29
2 37
3 20
4 24
5 33 28.6
6 29 28.6
7 11 23.4
8 40 27.4
9 31 28.8
10 36 29.4
11 15 26.6
12 41 32.6
13 47 34
14 17 31.2
15 46 33.2
16 16 33.4
17 37 32.6
18 21 27.4
19 39 31.8
20 12 25
21 44 30.6
22 35 30.2
23 20 30
24 26 27.4
25 41 33.2
26 13 27
27 41 28.2
28 14 27
29 20 25.8
30 47 27
This is pretty trivial using a spreadsheet, but I would like to be able to do it with
https://redd.it/146abdr
@r_bash
I think I may be getting way out of my ability here. If I have a file that looks like this:
data.txt:
Day Data
1 29
2 37
3 20
4 24
5 33
6 29
7 11
8 40
9 31
10 36
11 15
12 41
13 47
14 17
15 46
16 16
17 37
18 21
19 39
20 12
21 44
22 35
23 20
24 26
25 41
26 13
27 41
28 14
29 20
30 47
I would like to add a running average of the previous 5 days. So that given the data file, I would output:
Day Data Running 5 day average
1 29
2 37
3 20
4 24
5 33 28.6
6 29 28.6
7 11 23.4
8 40 27.4
9 31 28.8
10 36 29.4
11 15 26.6
12 41 32.6
13 47 34
14 17 31.2
15 46 33.2
16 16 33.4
17 37 32.6
18 21 27.4
19 39 31.8
20 12 25
21 44 30.6
22 35 30.2
23 20 30
24 26 27.4
25 41 33.2
26 13 27
27 41 28.2
28 14 27
29 20 25.8
30 47 27
This is pretty trivial using a spreadsheet, but I would like to be able to do it with
awk, or datamash (or whatever), but I can't seem to wrap my head around it. The logic is just add today's data to the previous 4 days and divide by 5.https://redd.it/146abdr
@r_bash
Reddit
r/bash on Reddit: Running weekly average
Posted by u/go_comatose_for_me - No votes and no comments
My bash module framework now supports interfaces and inheritance
https://m10k.eu/2023/06/10/toolbox-interfaces.html
https://redd.it/146mgxn
@r_bash
https://m10k.eu/2023/06/10/toolbox-interfaces.html
https://redd.it/146mgxn
@r_bash
Modules, frameworks, libararies
What is everyone's thoughts on modules/libraries/frameworks for bash? Oftenly people share their new custom library, mostly written in improper code and little to no proper documentation. Things like calling their custom functions, for example:
— Are syntactically just unappealing. We all know many things aren't supported in pure bash and therefore probably shouldn't be extended by using bash. Bash is not written in bash, it's written in C. Why are these so called custom libararies not written in C to properly extend bash? Better yet, why not attempt to include it in the source itself?
Saving 'boilerplate' code is one thing, but these attempts usually go way past that by trying to make things possible that shouldn't be, like interfaces and types for example. I wrote my own in the past without intention to extend bash itself but make it's current capabilities a bit simpler. Still I never use it myself
Maybe people don't realize they could be contributing to a bigger picture by extending bash source itself, so the wheel ends up reinvented endlessly
Curious what everyone things about these custom modules/frameworks/libraries that are available and if people really use them in every (most) project(s) they write. Let me know what you think..
https://redd.it/146rm8m
@r_bash
What is everyone's thoughts on modules/libraries/frameworks for bash? Oftenly people share their new custom library, mostly written in improper code and little to no proper documentation. Things like calling their custom functions, for example:
include a \
b \
c
— Are syntactically just unappealing. We all know many things aren't supported in pure bash and therefore probably shouldn't be extended by using bash. Bash is not written in bash, it's written in C. Why are these so called custom libararies not written in C to properly extend bash? Better yet, why not attempt to include it in the source itself?
Saving 'boilerplate' code is one thing, but these attempts usually go way past that by trying to make things possible that shouldn't be, like interfaces and types for example. I wrote my own in the past without intention to extend bash itself but make it's current capabilities a bit simpler. Still I never use it myself
Maybe people don't realize they could be contributing to a bigger picture by extending bash source itself, so the wheel ends up reinvented endlessly
Curious what everyone things about these custom modules/frameworks/libraries that are available and if people really use them in every (most) project(s) they write. Let me know what you think..
https://redd.it/146rm8m
@r_bash
Reddit
r/bash on Reddit: Modules, frameworks, libararies
Posted by u/wick3dr0se - No votes and 1 comment