monthly crontab jobs
Any idea how i can get a crontab job to run on every 2nd Wednesday of each month? not sure i can get that scheduled using crontab
https://redd.it/10gddja
@r_bash
Any idea how i can get a crontab job to run on every 2nd Wednesday of each month? not sure i can get that scheduled using crontab
https://redd.it/10gddja
@r_bash
reddit
monthly crontab jobs
Any idea how i can get a crontab job to run on every 2nd Wednesday of each month? not sure i can get that scheduled using crontab
pls help with bluetoothctl wrapper noscript ("Missing dev argument")
Hi everybody,
I am trying to write a wrapper noscript for
I base it on this arch wiki entry. THIS is my noscript (pastebin link).
When I run
I don't understand this. The syntax is the same for connecting and disconnecting; the functions are constructed accordingly. Yet one works, the other does not.
When I manually run
Can you please tell me what I need to change in order to make connect work as well? Thank you in advance for your help :)
https://redd.it/10grvms
@r_bash
Hi everybody,
I am trying to write a wrapper noscript for
bluetoothctl to easily connect/disconnect particular devices.I base it on this arch wiki entry. THIS is my noscript (pastebin link).
When I run
bluetoothhandler.sh trennen az_lautsprecher, it will disconnect that device and show the expected output that bluetoothctl produces; however, when I run bluetoothhandler.sh verbinden az_lautsprecher, I just get Missing dev argument.I don't understand this. The syntax is the same for connecting and disconnecting; the functions are constructed accordingly. Yet one works, the other does not.
When I manually run
bluetoothctl -- connect AB:06:CD:49:EF:E3 in the terminal, it works fine as well. When the noscript runs it, it won't work at all, while disconnect does work either way (both in the noscript and in the terminal).Can you please tell me what I need to change in order to make connect work as well? Thank you in advance for your help :)
https://redd.it/10grvms
@r_bash
mv: cannot stat?
inotifywait -m /home/aku/Downloads -e create -e moved_to |
while read directory action file; do
if [[ "$file" =~ .*png$ || "$file" =~ .*jpg$ || "$file" =~ .*gif$ || "$file" =~ .*webm$ ]]; then
sleep 4
echo "$file"
echo $(mv "$file" "/home/aku/Pictures/Downloads")
fi
done
I have this pretty simple shell noscript, which takes pictures that are saved to my downloads folder, then moves them to a different folder. Every time I try and test it, I get an error: cannot stat: no file or directory.
Any advice? I think the issue is with this line : echo $(mv "$file" "/home/aku/Pictures/Downloads"), as you can probably tell I've experimented with quite a few syntax and nothing has worked.
https://redd.it/10gul4c
@r_bash
inotifywait -m /home/aku/Downloads -e create -e moved_to |
while read directory action file; do
if [[ "$file" =~ .*png$ || "$file" =~ .*jpg$ || "$file" =~ .*gif$ || "$file" =~ .*webm$ ]]; then
sleep 4
echo "$file"
echo $(mv "$file" "/home/aku/Pictures/Downloads")
fi
done
I have this pretty simple shell noscript, which takes pictures that are saved to my downloads folder, then moves them to a different folder. Every time I try and test it, I get an error: cannot stat: no file or directory.
Any advice? I think the issue is with this line : echo $(mv "$file" "/home/aku/Pictures/Downloads"), as you can probably tell I've experimented with quite a few syntax and nothing has worked.
https://redd.it/10gul4c
@r_bash
reddit
mv: cannot stat?
inotifywait -m /home/aku/Downloads -e create -e moved_to | while read directory action file; do if [[ "$file" =~ .*png$ || "$file" =~...
Help needed with getting all the lines containing <noscript></noscript> for a simple rss noscript
So this is the basic noscript:
>\#!/bin/bash
\# URL of the RSS feed
FEED_URL=" http://rss.cnn.com/rss/cnn\_topstories.rss"
\# Download the RSS feed
curl -s $FEED_URL > feed.xml
\# Extract the article noscripts
grep -E "<noscript>[\^<\]+</noscript>" feed.xml | sed -e "s/<noscript>//" -e "s/<\\/noscript>//"
The problem is that it gets all the xml and the grep and sed commands aren't doing anything.
I also tried these patterns:
>grep -E "<noscript>[\^<\]+</noscript>" feed.xml | sed 's/<noscript>\\|<\\/noscript>//g'
and:
>grep -E "<noscript>[\^<\]+</noscript>" cnn_topstories.rss | sed -n -e "s/<noscript>//" -e "s/<\\/noscript>//p" | tr -d '\^[0-9\]\\{1,\\}[:blank:\]'
and even with awk:
>grep -E "<noscript>[\^<\]+</noscript>" cnn_topstories.rss | awk -F'<noscript>|</noscript>' '{print $2}'
but nothing seems to do what I want.
I just want to get the noscript tags from the xml and echo all of them in a new line.
is that too much to ask LoL?
Any help is much appreciated
https://redd.it/10gb6mq
@r_bash
So this is the basic noscript:
>\#!/bin/bash
\# URL of the RSS feed
FEED_URL=" http://rss.cnn.com/rss/cnn\_topstories.rss"
\# Download the RSS feed
curl -s $FEED_URL > feed.xml
\# Extract the article noscripts
grep -E "<noscript>[\^<\]+</noscript>" feed.xml | sed -e "s/<noscript>//" -e "s/<\\/noscript>//"
The problem is that it gets all the xml and the grep and sed commands aren't doing anything.
I also tried these patterns:
>grep -E "<noscript>[\^<\]+</noscript>" feed.xml | sed 's/<noscript>\\|<\\/noscript>//g'
and:
>grep -E "<noscript>[\^<\]+</noscript>" cnn_topstories.rss | sed -n -e "s/<noscript>//" -e "s/<\\/noscript>//p" | tr -d '\^[0-9\]\\{1,\\}[:blank:\]'
and even with awk:
>grep -E "<noscript>[\^<\]+</noscript>" cnn_topstories.rss | awk -F'<noscript>|</noscript>' '{print $2}'
but nothing seems to do what I want.
I just want to get the noscript tags from the xml and echo all of them in a new line.
is that too much to ask LoL?
Any help is much appreciated
https://redd.it/10gb6mq
@r_bash
reddit
Help needed with getting all the lines containing <noscript></noscript>...
So this is the basic noscript: >\#!/bin/bash \# URL of the RSS feed FEED\_URL="...
How to increment an index refer to parameter to read the value?
First time doing any bash noscripting so having some difficulties with it being so low level
Given the noscript below, how do I increase the index in the second part of the echo statement so that it prints the next parameter value (i.e print the first parameter, then print the second parameter)
So, for example running is as 'sh mynoscript.sh param1 param2' should echo:
param1
param2
​
Currently its just printing param1 twice, and I've tried everything I've found online, but just cant get it to work
https://redd.it/10h2tjy
@r_bash
First time doing any bash noscripting so having some difficulties with it being so low level
Given the noscript below, how do I increase the index in the second part of the echo statement so that it prints the next parameter value (i.e print the first parameter, then print the second parameter)
paramIndex=1while [ $paramIndex -le $# ]doecho "${!paramIndex}" "${!paramIndex}"((paramIndex++))doneSo, for example running is as 'sh mynoscript.sh param1 param2' should echo:
param1
param2
​
Currently its just printing param1 twice, and I've tried everything I've found online, but just cant get it to work
https://redd.it/10h2tjy
@r_bash
Calculate sum of pattern occurence in text file
So I have a text file, with each line being "X tests passed". X can be any number. I want to loop through the whole file and add up all the numbers, so the output would be "N tests passed" where N is the sum of all tests passed. How do I do this?
https://redd.it/10h2i85
@r_bash
So I have a text file, with each line being "X tests passed". X can be any number. I want to loop through the whole file and add up all the numbers, so the output would be "N tests passed" where N is the sum of all tests passed. How do I do this?
https://redd.it/10h2i85
@r_bash
reddit
Calculate sum of pattern occurence in text file
So I have a text file, with each line being "X tests passed". X can be any number. I want to loop through the whole file and add up all the...
Need help with formatting of collected data
My goal is to automatically name computers in the organization using a noscript. The only data required for the naming is Locale-ModelType-CurrentUserName (i.e. us-mbp-kunkmaster.flex)
The furthest I have gotten in the noscript is actually pulling the data that I need. What I cannot figure out is how to format that data into the end result. For example, the noscript in its current form will echo "MacBookPro". However, I want that to be translated to "mbp". Or if it echos "MacBookAir", that translates into "mba". I just cannot figure out the if/then as when I create those commands, the noscript errors out.
I will tip anyone that can solve this for me as I will also use it to learn how to automate several other things.
#!/usr/bin/env bash
# get currently logged in user
user=$( /usr/bin/stat -f "%Su" /dev/console )
echo "Current user is - $user"
# Get the Model of the Machine
model=$(system_profiler SPHardwareDataType | awk '/Model Name/ {print $3 $4}')
echo "Machine type is - $model"
#Get Locale of Machine
locale=$(locale | awk '/LANG/ {print $1}')
echo "Locale is - $locale"
https://redd.it/10hf2fz
@r_bash
My goal is to automatically name computers in the organization using a noscript. The only data required for the naming is Locale-ModelType-CurrentUserName (i.e. us-mbp-kunkmaster.flex)
The furthest I have gotten in the noscript is actually pulling the data that I need. What I cannot figure out is how to format that data into the end result. For example, the noscript in its current form will echo "MacBookPro". However, I want that to be translated to "mbp". Or if it echos "MacBookAir", that translates into "mba". I just cannot figure out the if/then as when I create those commands, the noscript errors out.
I will tip anyone that can solve this for me as I will also use it to learn how to automate several other things.
#!/usr/bin/env bash
# get currently logged in user
user=$( /usr/bin/stat -f "%Su" /dev/console )
echo "Current user is - $user"
# Get the Model of the Machine
model=$(system_profiler SPHardwareDataType | awk '/Model Name/ {print $3 $4}')
echo "Machine type is - $model"
#Get Locale of Machine
locale=$(locale | awk '/LANG/ {print $1}')
echo "Locale is - $locale"
https://redd.it/10hf2fz
@r_bash
reddit
Need help with formatting of collected data
My goal is to automatically name computers in the organization using a noscript. The only data required for the naming is...
Text separated by new lines acts different than text separated by spaces
I have this noscript that finds and deletes unwanted text (badwords) in directory names, subdirectory names and file names in the current working directory. The unwanted text is in the file /home/oops/badwords.txt
The noscript works as it should when the badwords in /home/oops/badwords.txt are all on seperate lines:
oops@8740w:~$ cat badwords.txt
CDRip
YIFY
AAC_5_1
WEBRip
YTS_MX
When I run the noscript those words are all deleted from the folder and file names in the working directory when they are on their own lines.
However, when the badwords in /home/oops/badwords.txt are just seperated by spaces:
oops@8740w:~$ cat badwords.text
CDRip YIFY AAC_5_1 WEBRip YTS_MX
then the noscript fails and doesn't find and delete the badwords.
Here's the noscript:
*********************************************
#!/bin/bash
input="/home/oops/badwords.txt"
while IFS= read -r line
do
echo "$line"
find -name "*$line*" -print0 | sort -rz | while read -d $'\0' f; do mv -v "$f" "$(dirname "$f")/$(basename "${f//$line/}")"; done
#
#
done < "$input"
**************************************************************************
I know while IFS= read -r line is working when the text is separated by spaces because the echo "$line"
prints the badwords when they're separated by spaces
But when "$line" gets passed into the find command it doesn't find and delete the badwords.
I'm thinking I need to add a newline somehow during the read process or maybe I don't have the right syntax(?) in the read command.
It doesn't really matter to me if the text in badwords.txt is all on separate lines but there's something I'm missing here and it just bothers me that I can't find the answer.
Please, go easy on me, I'm learning this on my own and know I haven't used the right words. Tried shellcheck but it doesn't see a problem.
I'd much appreciate a kick in the right direction.
https://redd.it/10hgw08
@r_bash
I have this noscript that finds and deletes unwanted text (badwords) in directory names, subdirectory names and file names in the current working directory. The unwanted text is in the file /home/oops/badwords.txt
The noscript works as it should when the badwords in /home/oops/badwords.txt are all on seperate lines:
oops@8740w:~$ cat badwords.txt
CDRip
YIFY
AAC_5_1
WEBRip
YTS_MX
When I run the noscript those words are all deleted from the folder and file names in the working directory when they are on their own lines.
However, when the badwords in /home/oops/badwords.txt are just seperated by spaces:
oops@8740w:~$ cat badwords.text
CDRip YIFY AAC_5_1 WEBRip YTS_MX
then the noscript fails and doesn't find and delete the badwords.
Here's the noscript:
*********************************************
#!/bin/bash
input="/home/oops/badwords.txt"
while IFS= read -r line
do
echo "$line"
find -name "*$line*" -print0 | sort -rz | while read -d $'\0' f; do mv -v "$f" "$(dirname "$f")/$(basename "${f//$line/}")"; done
#
#
done < "$input"
**************************************************************************
I know while IFS= read -r line is working when the text is separated by spaces because the echo "$line"
prints the badwords when they're separated by spaces
But when "$line" gets passed into the find command it doesn't find and delete the badwords.
I'm thinking I need to add a newline somehow during the read process or maybe I don't have the right syntax(?) in the read command.
It doesn't really matter to me if the text in badwords.txt is all on separate lines but there's something I'm missing here and it just bothers me that I can't find the answer.
Please, go easy on me, I'm learning this on my own and know I haven't used the right words. Tried shellcheck but it doesn't see a problem.
I'd much appreciate a kick in the right direction.
https://redd.it/10hgw08
@r_bash
reddit
Text separated by new lines acts different than text separated by...
I have this noscript that finds and deletes unwanted text (badwords) in directory names, subdirectory names and file names in the current working...
No output
Hi guys im new to shellbash , im running this on ubuntu virtual box ,When i run my program I don't get any errors. The program asks me for a number i write it in and then it just stops, could anybody tell me why the digits are not printing? thanks in advance
program
https://redd.it/10hsrpe
@r_bash
Hi guys im new to shellbash , im running this on ubuntu virtual box ,When i run my program I don't get any errors. The program asks me for a number i write it in and then it just stops, could anybody tell me why the digits are not printing? thanks in advance
program
https://redd.it/10hsrpe
@r_bash
read -a variable <<< $dataset (Change delimiter)
The data set I am working with has spaces.
Structure:
SUBURB TOWN NUM1 NUM2
Since Suburbs and Towns often have Spaces in i have chosen to use the typical CSV structure.
VALLEY VIEW,JONES TOWN,2032,2033
Using the read command I can easily save it into variables using the dataset but the issue is that read -a defaults to a space character as the delimiter, so the above becomes...
${variable[0\]} is VALLEY
${variable[1\]} is VIEW,JONES
${variable[2\]} is TOWN,2032,2033
${variable[3\]} is null
I need to use the comma character as the delimiter so I can get the following...
${variable[0\]} is VALLEY VIEW
${variable[1\]} is JONES TOWN
${variable[2\]} is 2032
${variable[3\]} is 2033
I tried using ...
read -d "," -a variable <<< $dataset
​
No difference. Any one got some idea?
https://redd.it/10i1iiu
@r_bash
The data set I am working with has spaces.
Structure:
SUBURB TOWN NUM1 NUM2
Since Suburbs and Towns often have Spaces in i have chosen to use the typical CSV structure.
VALLEY VIEW,JONES TOWN,2032,2033
Using the read command I can easily save it into variables using the dataset but the issue is that read -a defaults to a space character as the delimiter, so the above becomes...
${variable[0\]} is VALLEY
${variable[1\]} is VIEW,JONES
${variable[2\]} is TOWN,2032,2033
${variable[3\]} is null
I need to use the comma character as the delimiter so I can get the following...
${variable[0\]} is VALLEY VIEW
${variable[1\]} is JONES TOWN
${variable[2\]} is 2032
${variable[3\]} is 2033
I tried using ...
read -d "," -a variable <<< $dataset
​
No difference. Any one got some idea?
https://redd.it/10i1iiu
@r_bash
reddit
read -a variable <<< $dataset (Change delimiter)
The data set I am working with has spaces. Structure: SUBURB TOWN NUM1 NUM2 Since Suburbs and Towns often have Spaces in i have chosen to...
How to uses pipes with an executable that does not support shebang line?
So when we do this
#!/usr/bin/env wasmtime
(module
;; ...
)
this happens
$ ./demo
Error: failed to run main module
Caused by:
0: if you're trying to run a precompiled module, pass --allow-precompiled
1: expected
--> ./demo:1:1
|
1 | #!/usr/bin/env wasmtime
| ^
So far I have tried
#!/usr/bin/sh
wasmtime run /dev/stdin <<END
(module
;; ...
END
and
#!/usr/bin/sh
cat >foo.wat <<END
(module
;; ...
)
END
wasmtime run foo.wat
to no avail.
What I am trying to do is create a WebAssembly Native Messaging host that functions the same as C, C++, Python, JavaScript engine Native Messaging hosts.
Thanks in advance for your help.
https://redd.it/10i09se
@r_bash
wasmtime does not support shebang; see https://github.com/bytecodealliance/wasmtime/issues/3715, https://github.com/bytecodealliance/wasmtime/issues/5614.So when we do this
#!/usr/bin/env wasmtime
(module
;; ...
)
this happens
$ ./demo
Error: failed to run main module
./demoCaused by:
0: if you're trying to run a precompiled module, pass --allow-precompiled
1: expected
(--> ./demo:1:1
|
1 | #!/usr/bin/env wasmtime
| ^
So far I have tried
#!/usr/bin/sh
wasmtime run /dev/stdin <<END
(module
;; ...
END
and
#!/usr/bin/sh
cat >foo.wat <<END
(module
;; ...
)
END
wasmtime run foo.wat
to no avail.
What I am trying to do is create a WebAssembly Native Messaging host that functions the same as C, C++, Python, JavaScript engine Native Messaging hosts.
Thanks in advance for your help.
https://redd.it/10i09se
@r_bash
GitHub
Support shebang for command-line wasmtime noscripts · Issue #3715 · bytecodealliance/wasmtime
Feature Make wasmtime hip to a shebang at the first line of the file, e.g.: #!/usr/local/bin/wasmtime followed by the text-format wasm code as usual. Currently, the shell runs wasmtime and feeds it...
Newline & carriage return not behaving like I expect with echo command.
I'm trying to make a one-line terminal command to append an alias to my .bashrc file. I want 2 returns/newlines/carriage returns so the file isn't a pain to read, then a commented "noscript" explaining the line's function, then the alias command.
I want it to look like:
#last line of the file
#Title/explanatory statement
alias quickbackupC1='rsync -ac --info=progress2 --delete /home/user/{Downloads,Desktop,Documents,GitHub,Pictures,Videos} /media/user/CRUCIALX6-1'
Here's what I came up with:
echo "\r\r#Alias for quick backup to drive 1\ralias quickbackupC1='rsync -ac --info=progress2 --delete /home/user/{Downloads,Desktop,Documents,GitHub,Pictures,Videos} /media/user/CRUCIALX6-1'" >> /home/user/.bashrc
All this does it paste everything inside the double quotes into the file like:
#last line of the file
\r\r#Alias for quick backup to drive 1\ralias quickbackupC1='rsync -ac --info=progress2 --delete /home/user/{Downloads,Desktop,Documents,GitHub,Pictures,Videos} /media/user/CRUCIALX6-1'
I've tried both \n and \r to insert blank lines. Where am I going wrong?
https://redd.it/10i6uoa
@r_bash
I'm trying to make a one-line terminal command to append an alias to my .bashrc file. I want 2 returns/newlines/carriage returns so the file isn't a pain to read, then a commented "noscript" explaining the line's function, then the alias command.
I want it to look like:
#last line of the file
#Title/explanatory statement
alias quickbackupC1='rsync -ac --info=progress2 --delete /home/user/{Downloads,Desktop,Documents,GitHub,Pictures,Videos} /media/user/CRUCIALX6-1'
Here's what I came up with:
echo "\r\r#Alias for quick backup to drive 1\ralias quickbackupC1='rsync -ac --info=progress2 --delete /home/user/{Downloads,Desktop,Documents,GitHub,Pictures,Videos} /media/user/CRUCIALX6-1'" >> /home/user/.bashrc
All this does it paste everything inside the double quotes into the file like:
#last line of the file
\r\r#Alias for quick backup to drive 1\ralias quickbackupC1='rsync -ac --info=progress2 --delete /home/user/{Downloads,Desktop,Documents,GitHub,Pictures,Videos} /media/user/CRUCIALX6-1'
I've tried both \n and \r to insert blank lines. Where am I going wrong?
https://redd.it/10i6uoa
@r_bash
reddit
Newline & carriage return not behaving like I expect with echo...
I'm trying to make a one-line terminal command to append an alias to my .bashrc file. I want 2 returns/newlines/carriage returns so the file isn't...
Why are my strings not concatenating? The current output is just "viewers!"
https://redd.it/10ic7w0
@r_bash
https://redd.it/10ic7w0
@r_bash
neovim on gitbash
im using gitbash as my terminal and i want to install neovim to it i already got vim and it works fine but hot to install neovim !!
https://redd.it/10iixqh
@r_bash
im using gitbash as my terminal and i want to install neovim to it i already got vim and it works fine but hot to install neovim !!
https://redd.it/10iixqh
@r_bash
reddit
neovim on gitbash
im using gitbash as my terminal and i want to install neovim to it i already got vim and it works fine but hot to install neovim !!
Compiling .sh files
Hey all , my task is to run a noscript ive made using makefile,I know that compiling .cpp files is with g++, but is there a command for compiling .sh files?
i just want to do something like g++ filea.sh fileb.sh \-o run
but this command returns following errors:
/usr/bin/ld:lab03a.sh: file format not recognized; treating as linker noscript
/usr/bin/ld:lab03a.sh:5: syntax error
collect2: error: ld returned 1 exit status
https://redd.it/10ijqdk
@r_bash
Hey all , my task is to run a noscript ive made using makefile,I know that compiling .cpp files is with g++, but is there a command for compiling .sh files?
i just want to do something like g++ filea.sh fileb.sh \-o run
but this command returns following errors:
/usr/bin/ld:lab03a.sh: file format not recognized; treating as linker noscript
/usr/bin/ld:lab03a.sh:5: syntax error
collect2: error: ld returned 1 exit status
https://redd.it/10ijqdk
@r_bash
How can I chain commands together in bash that send each one into the background? Keep getting syntax errors, and I'm wondering if there's a way.
Here is an example of what I am trying to do:
Both give syntax errors at
https://redd.it/10iqwh0
@r_bash
Here is an example of what I am trying to do:
less .bashrc &; less .bashrc &less .bashrc & && less .bashrc &Both give syntax errors at
; or &&, respectively. Is there a way to do this that can work in chained commands like this?https://redd.it/10iqwh0
@r_bash
reddit
How can I chain commands together in bash that send each one into...
Here is an example of what I am trying to do: `less .bashrc &; less .bashrc &` `less .bashrc & && less .bashrc &` Both give syntax errors at...
Is polling in a separate noscript the correct approach to terminate process substitution
#!wasmtime
(module
;; ...
)
I've cobbled together a workaround using a separate noscript. Is the the correct approach to proceed?
nmcwat.sh
#!/bin/bash
# https://www.reddit.com/r/bash/comments/10i09se/comment/j5blsrw/
noscript='
(module
;; ...
)
'
./killwasmtime.sh &
./wasmtime <(printf '%s' "$noscript")
killwasmtime.sh
#!/bin/bash
while pgrep -f nmcwat.sh > /dev/null
do
sleep 1
done
killall -9 wasmtime
exit 0
https://redd.it/10ixjx2
@r_bash
wasmtime does not support using shebang then raw WAT for the noscript body, so we can't do#!wasmtime
(module
;; ...
)
I've cobbled together a workaround using a separate noscript. Is the the correct approach to proceed?
nmcwat.sh
#!/bin/bash
# https://www.reddit.com/r/bash/comments/10i09se/comment/j5blsrw/
noscript='
(module
;; ...
)
'
./killwasmtime.sh &
./wasmtime <(printf '%s' "$noscript")
killwasmtime.sh
#!/bin/bash
while pgrep -f nmcwat.sh > /dev/null
do
sleep 1
done
killall -9 wasmtime
exit 0
https://redd.it/10ixjx2
@r_bash
reddit
How to uses pipes with an executable that does not support shebang...
**SOLVED** ~~wasmtime does not support shebang~~; see...
Grep for multi-character patterns in random order
Is there a way to grep for multiple patterns, each with several characters, in random order?
What I am trying to do would be something like
However, that returns all lines containing any character in
https://redd.it/10iz8ke
@r_bash
Is there a way to grep for multiple patterns, each with several characters, in random order?
What I am trying to do would be something like
echo -e $inputline1 $inputline2 | grep [pattern][another_pattern]However, that returns all lines containing any character in
pattern right before any character in another_pattern, while I need something that returns all lines that match either pattern another_pattern or another_pattern pattern, preferably without nested greps.https://redd.it/10iz8ke
@r_bash
reddit
Grep for multi-character patterns in random order
Is there a way to grep for multiple patterns, each with several characters, in random order? What I am trying to do would be something...
Correct way to create a noscript-accessible environmental variable
Context
I've created my own equivalent of f.lux using xsct and a bash noscript. One feature I have is the ability to disable the bash noscript temporarily via a terminal command "evmode off" and to enable it via "evmode on". As the noscript runs once per minute via Cron, I need some way of preserving this setting outside the noscript itself.
Question
Right now, I just have a text file called "evmodeon"; if I enter "evmode off" into the terminal, the file is renamed to evmodeoff. The noscript checks for the presence of either file in order to determine whether it should run or not.
This seems like it is the wrong way to do it. I can always modify it so that the noscript checks the content of the file instead of the file name, but that still seems like I've just created a janky version of environment variables. However, as I've learned through my attempts to use actual environment variables, they are a pain to work with since I can't easily modify them with the noscript itself, and if I use source whenever the noscript exits the whole terminal session goes kaput. Indeed, that's why I used the file-name-as-variable approach to begin with.
What is the correct way of creating a system-wide variable that any noscript can reference and modify as needed? Should I just make a text file in my home folder called "variables" and pull everything from there, or is there an easier way?
https://redd.it/10j0wof
@r_bash
Context
I've created my own equivalent of f.lux using xsct and a bash noscript. One feature I have is the ability to disable the bash noscript temporarily via a terminal command "evmode off" and to enable it via "evmode on". As the noscript runs once per minute via Cron, I need some way of preserving this setting outside the noscript itself.
Question
Right now, I just have a text file called "evmodeon"; if I enter "evmode off" into the terminal, the file is renamed to evmodeoff. The noscript checks for the presence of either file in order to determine whether it should run or not.
This seems like it is the wrong way to do it. I can always modify it so that the noscript checks the content of the file instead of the file name, but that still seems like I've just created a janky version of environment variables. However, as I've learned through my attempts to use actual environment variables, they are a pain to work with since I can't easily modify them with the noscript itself, and if I use source whenever the noscript exits the whole terminal session goes kaput. Indeed, that's why I used the file-name-as-variable approach to begin with.
What is the correct way of creating a system-wide variable that any noscript can reference and modify as needed? Should I just make a text file in my home folder called "variables" and pull everything from there, or is there an easier way?
https://redd.it/10j0wof
@r_bash
reddit
Correct way to create a noscript-accessible environmental variable
**Context** I've created my own equivalent of f.lux using xsct and a bash noscript. One feature I have is the ability to disable the bash noscript...
Wait command questions
The following example has a wait command 4 times.
if [ $2 == "local" ]; then
case ${srcOS,,} in
ubuntu|debian)
sudo service plexmediaserver $1
wait
linux)
sudo systemctl $1 plexmediaserver
wait
;;
esac
elif [[ $2 == "remote" ]]; then
case ${dstOS,,} in
ubuntu|debian)
ssh user@IP "service plexmediaserver $1"
wait
linux)
ssh user@IP "systemctl $1 plexmediaserver"
wait
;;
esac
fi
Can I delete the 4 wait commands and add 1 wait command after fi ?
if [ <test> ]; then
command foo
else
command bar
fi
wait
For the
https://redd.it/10j1wgs
@r_bash
The following example has a wait command 4 times.
if [ $2 == "local" ]; then
case ${srcOS,,} in
ubuntu|debian)
sudo service plexmediaserver $1
wait
linux)
sudo systemctl $1 plexmediaserver
wait
;;
esac
elif [[ $2 == "remote" ]]; then
case ${dstOS,,} in
ubuntu|debian)
ssh user@IP "service plexmediaserver $1"
wait
linux)
ssh user@IP "systemctl $1 plexmediaserver"
wait
;;
esac
fi
Can I delete the 4 wait commands and add 1 wait command after fi ?
if [ <test> ]; then
command foo
else
command bar
fi
wait
For the
ssh user@IP command is wait going to wait for ssh or the command?https://redd.it/10j1wgs
@r_bash
reddit
Wait command questions
The following example has a wait command 4 times. if [[ $2 == "local" ]]; then case ${src_OS,,} in ubuntu|debian) ...