Creating a grep pattern that would work like this: <Keyword><any amount of special characters or lowercase leters><any numbers and uppercase letters>
I wanted to create a scipt that can find Invoice number from text. It basically converts PDF to txt and then searches for company name and Invoice number. And I have a problem with invoice number.
​
For now I used this to get the invoice number (output.txt is the converted PDF)
​
```
\#!/bin/bash
\#some code before
​
keyword1="Rechnung"
keyword2="Invoice"
​
\# Use grep to search for the pattern in the file and extract only the matched (non-empty) parts of a matching line
output=$(grep -ioE "$keyword1[\^0-9\]*([A-Z\]*[0-9\]+)|$keyword2[\^0-9\]*([A-Z\]*[0-9\]+)" "$path/$fileName/output.txt")
​
​
\# Use sed to extract the first set of letters and numbers that comes after keyword
result_array=($(echo $output | awk -F '[\^[:alnum:\]\]' '{for (i=1; i<=NF; i++) if ($i \~ /[A-Z\]*[0-9\]+/) print $i}'))
​
\#some code after, where it finds the longest elemnt in the array
```
THe $output get the line with keyword, and then $result_array gets only the number
​
​
And it works if, for example the invoice number itself only has number (91895851851) or if it has letter at the start (RE19515515). But some of the invoices have letter beetween the bumbers, for example AA1111AA11. And if this is the case, rhis noscript will only take AA1111 and leave everything else.
​
So I need a pattern that would work like this:
<Keyword><any amount of spaces, special characters or lowercase leters><any numbers and uppercase letters>
And it should return only the invoice number
​
It should work on all cases below:
​
"invoice nunmber is RE5050AE5050" ==> "RE5050AE5050"
​
"invoiceNumber: - . | RE5050AE5050" ==> "RE5050AE5050"
​
and so on.
https://redd.it/10e8mh7
@r_bash
I wanted to create a scipt that can find Invoice number from text. It basically converts PDF to txt and then searches for company name and Invoice number. And I have a problem with invoice number.
​
For now I used this to get the invoice number (output.txt is the converted PDF)
​
```
\#!/bin/bash
\#some code before
​
keyword1="Rechnung"
keyword2="Invoice"
​
\# Use grep to search for the pattern in the file and extract only the matched (non-empty) parts of a matching line
output=$(grep -ioE "$keyword1[\^0-9\]*([A-Z\]*[0-9\]+)|$keyword2[\^0-9\]*([A-Z\]*[0-9\]+)" "$path/$fileName/output.txt")
​
​
\# Use sed to extract the first set of letters and numbers that comes after keyword
result_array=($(echo $output | awk -F '[\^[:alnum:\]\]' '{for (i=1; i<=NF; i++) if ($i \~ /[A-Z\]*[0-9\]+/) print $i}'))
​
\#some code after, where it finds the longest elemnt in the array
```
THe $output get the line with keyword, and then $result_array gets only the number
​
​
And it works if, for example the invoice number itself only has number (91895851851) or if it has letter at the start (RE19515515). But some of the invoices have letter beetween the bumbers, for example AA1111AA11. And if this is the case, rhis noscript will only take AA1111 and leave everything else.
​
So I need a pattern that would work like this:
<Keyword><any amount of spaces, special characters or lowercase leters><any numbers and uppercase letters>
And it should return only the invoice number
​
It should work on all cases below:
​
"invoice nunmber is RE5050AE5050" ==> "RE5050AE5050"
​
"invoiceNumber: - . | RE5050AE5050" ==> "RE5050AE5050"
​
and so on.
https://redd.it/10e8mh7
@r_bash
reddit
Creating a grep pattern that would work like this: <Keyword><any...
I wanted to create a scipt that can find Invoice number from text. It basically converts PDF to txt and then searches for company name and Invoice...
Unix/Linux Command Combinations That Every Developer Should Know
https://levelup.gitconnected.com/unix-linux-command-combinations-that-every-developer-should-know-9ae475cf6568?sk=8f264980b4cb013c5536e23387c32275
https://redd.it/10efm3n
@r_bash
https://levelup.gitconnected.com/unix-linux-command-combinations-that-every-developer-should-know-9ae475cf6568?sk=8f264980b4cb013c5536e23387c32275
https://redd.it/10efm3n
@r_bash
Medium
Unix/Linux Command Combinations That Every Developer Should Know
Save your time by using these command combinations in your terminal and noscripts
vim in a while loop gets remaining lines as a buffer... can anyone help explain?
So I'm trying to edit a bunch of things, one at a time slowly, in a loop. I'm doing this with a
Here's exactly what I'm doing, in a simple/reproducible case:
# first line for r/bash folks who might not know about printf overloading
$ while read f; do echo "got '$f'" ;done < <(printf '%s\n' foo bar baz)
got 'foo'
got 'bar'
got 'baz'
# Okay now the case I'm asking for help with:
$ while read f; do vim "$f" ;done < <(printf '%s\n' foo bar baz)
expected: when I run the above, I'm expecting it's equivalent to doing:
# opens vim for each file, waits for vim to exit, then opens vim for the next...
for f in foo bar baz; do vim "$f"; done
actual/problem: strangely I find myself on a blank vim buffer (
:ls
1 %a + "No Name" line 1
2 "foo" line 0
I'm expecting vim to just have opened with a single buffer: editing
### Debugging
So I'm trying to reason about how it is that vim is clearly getting ... rr... more information. Here's what I tried:
note 1: print argument myself, to sanity check what's being passed to my command; see dummy
$ function argprinter() { printf 'arg: "%s"\n' $@; }
$ while read f; do argprinter "$f" ;done < <(printf '%s\n' foo bar baz)
arg: "foo"
arg: "bar"
arg: "baz"
note 2: So the above seems right, but I noticed if I do
https://redd.it/10egdhk
@r_bash
So I'm trying to edit a bunch of things, one at a time slowly, in a loop. I'm doing this with a
while loop (see wooledge's explainer on this `while` loop pattern and ProcessSubstitution). Problem: I'm seeing that vim only opens correctly with a for loop but not with a while loop. Can someone help point out what's happening here with the while loop and how to fix it properly?Here's exactly what I'm doing, in a simple/reproducible case:
# first line for r/bash folks who might not know about printf overloading
$ while read f; do echo "got '$f'" ;done < <(printf '%s\n' foo bar baz)
got 'foo'
got 'bar'
got 'baz'
# Okay now the case I'm asking for help with:
$ while read f; do vim "$f" ;done < <(printf '%s\n' foo bar baz)
expected: when I run the above, I'm expecting it's equivalent to doing:
# opens vim for each file, waits for vim to exit, then opens vim for the next...
for f in foo bar baz; do vim "$f"; done
actual/problem: strangely I find myself on a blank vim buffer (
[No Name]) with two lines bar followed by baz; If I inspect my buffers (to see if I got any reference to foo file, I do see it in the second buffer::ls
1 %a + "No Name" line 1
2 "foo" line 0
I'm expecting vim to just have opened with a single buffer: editing
foo file. Anyone know why this isn't happening?### Debugging
So I'm trying to reason about how it is that vim is clearly getting ... rr... more information. Here's what I tried:
note 1: print argument myself, to sanity check what's being passed to my command; see dummy
argprinter func:$ function argprinter() { printf 'arg: "%s"\n' $@; }
$ while read f; do argprinter "$f" ;done < <(printf '%s\n' foo bar baz)
arg: "foo"
arg: "bar"
arg: "baz"
note 2: So the above seems right, but I noticed if I do
:ar in vim I only see [foo] as expected. So it's just :ls buffer listing that's a mystery to me.https://redd.it/10egdhk
@r_bash
What tool is it ?
I changed my computer and re-install everything from scratch a month ago.
But I am missing a command/tool/setting or whatever that I had on the old computer that is related to browsing/scrolling up/down the output in terminal . There was a key bind that makes the cursor jump to the begging of the previous command in the terminal. I am not talking of a simple Page Up, the thing knows exactly how many pages to scroll up on terminal output to the beginning of previous command.
Which is this one ?
I really don't remember if it is something specific to bash (I only use bash) or it is something related to KDE/konsole....
https://redd.it/10egz0w
@r_bash
I changed my computer and re-install everything from scratch a month ago.
But I am missing a command/tool/setting or whatever that I had on the old computer that is related to browsing/scrolling up/down the output in terminal . There was a key bind that makes the cursor jump to the begging of the previous command in the terminal. I am not talking of a simple Page Up, the thing knows exactly how many pages to scroll up on terminal output to the beginning of previous command.
Which is this one ?
I really don't remember if it is something specific to bash (I only use bash) or it is something related to KDE/konsole....
https://redd.it/10egz0w
@r_bash
reddit
What tool is it ?
I changed my computer and re-install everything from scratch a month ago. But I am missing a command/tool/setting or whatever that I had on the...
Name of that utility which generates DAGs from text to SVG?
I've forgotten the name of the utility which generates DAGs from text, can you remember it?
You can give it a mydag.txt like:
In fact I'm very confident that was the basic syntax.
And then you can call:
And a DAG will be drawn in SVG format
I'm pretty sure this image used the same utlity because it matches the default style exactly:
https://en.wikipedia.org/wiki/Directed\_acyclic\_graph#/media/File:Tred-G.noscript
(p.s its not gnuplot as far as I can remember)
https://redd.it/10eraf3
@r_bash
I've forgotten the name of the utility which generates DAGs from text, can you remember it?
You can give it a mydag.txt like:
a -> b
b -> c
In fact I'm very confident that was the basic syntax.
And then you can call:
cat mydag.txt | program -t noscript -o out.noscript
And a DAG will be drawn in SVG format
I'm pretty sure this image used the same utlity because it matches the default style exactly:
https://en.wikipedia.org/wiki/Directed\_acyclic\_graph#/media/File:Tred-G.noscript
(p.s its not gnuplot as far as I can remember)
https://redd.it/10eraf3
@r_bash
trying to delete some apks and directories that malware placed on my phone keep getting access denied
https://redd.it/10evlv8
@r_bash
https://redd.it/10evlv8
@r_bash
reddit
trying to delete some apks and directories that malware placed on...
Posted in r/bash by u/TryingToLearnBash • 1 point and 0 comments
Another noscript
Hi everyone. Hope you all are doing well.
I am working on another noscript and I am having an issue. Sharing the noscript below:
#!/bin/bash
###########################
# Created by Diego Castro #
# and Ryan Curran #
###########################
<<'Tip'
Tip: instead of running the noscript like this: ./swaks..., you can do the following
Instead of running the noscript like this: ./swaks..., you can do the following:
1. vi ~/.bashrc
2. Add this line at the bottom: alias swaks='~/./swaks-core-lab1.sh' <- The directory changes depending on the folder you are saving the noscript.
3. Save changes - :x
4. source ~/.bashrc
Tip
# This noscript will just use the server to get the email in the lab for CORE - lab1
server=xx.xx.xxx.xx (can't share the IP)
ehlo="xxx.xxxxx" (another thing I can't share)
at="--attach"
read -p "Recipient: " recipient
read -p "Any attachments Y/n: " name
if [ ${name} == "y" ]
then
read -p "Attachment location Documents | Downloads | etc: " location
if [ ${location} == "Documents" ]
then
read -p "Name of the file: " fileDocument
$docLoc= "cd /mnt/c/Users/$USER/Documents/"
fileDoc=${docLoc}${fileDocument}
swaks -t ${recipient} -s ${server} -h ${ehlo} ${at} ${fileDoc}
elif [ ${location} == "Downloads" ]
then
read -p "Name of the file: " fileDownloads
$downLoc="/mnt/c/Users/$USER/Downloads/"
fileDown=${downLoc}${fileDownloads}
swaks -t ${recipient} -s ${server} -h ${ehlo} ${at} ${fileDown}
else
read -p "Location of the file: " fileDir
read -p "Name of the file: " fileName
otherLoc="/mnt/c/Users/$USER/"
slash="/"
fileElse="${otherLoc}${fileDir}${slash}${fileName}"
swaks -t ${recipient} -s ${server} -h ${ehlo} ${at} ${fileElse}
fi
elif [ ${name} == "n" ]
then
swaks -t ${recipient} -s ${server} -h ${ehlo}
else
echo "Error. Closing the program now."
exit 1
fi
The issue I am having now is when getting an attachment for the noscript, just for the options Downloads and Documents, the noscript gives an error on this line ${downLoc}${fileDownloads} for the Downloads options and, this one fileDoc=${docLoc}${fileDocument} for the Documents option. The only one that works is the first else which you can choose the directory. Any idea guys?
​
Thank you so much for your collaboration and effort.
https://redd.it/10f36rr
@r_bash
Hi everyone. Hope you all are doing well.
I am working on another noscript and I am having an issue. Sharing the noscript below:
#!/bin/bash
###########################
# Created by Diego Castro #
# and Ryan Curran #
###########################
<<'Tip'
Tip: instead of running the noscript like this: ./swaks..., you can do the following
Instead of running the noscript like this: ./swaks..., you can do the following:
1. vi ~/.bashrc
2. Add this line at the bottom: alias swaks='~/./swaks-core-lab1.sh' <- The directory changes depending on the folder you are saving the noscript.
3. Save changes - :x
4. source ~/.bashrc
Tip
# This noscript will just use the server to get the email in the lab for CORE - lab1
server=xx.xx.xxx.xx (can't share the IP)
ehlo="xxx.xxxxx" (another thing I can't share)
at="--attach"
read -p "Recipient: " recipient
read -p "Any attachments Y/n: " name
if [ ${name} == "y" ]
then
read -p "Attachment location Documents | Downloads | etc: " location
if [ ${location} == "Documents" ]
then
read -p "Name of the file: " fileDocument
$docLoc= "cd /mnt/c/Users/$USER/Documents/"
fileDoc=${docLoc}${fileDocument}
swaks -t ${recipient} -s ${server} -h ${ehlo} ${at} ${fileDoc}
elif [ ${location} == "Downloads" ]
then
read -p "Name of the file: " fileDownloads
$downLoc="/mnt/c/Users/$USER/Downloads/"
fileDown=${downLoc}${fileDownloads}
swaks -t ${recipient} -s ${server} -h ${ehlo} ${at} ${fileDown}
else
read -p "Location of the file: " fileDir
read -p "Name of the file: " fileName
otherLoc="/mnt/c/Users/$USER/"
slash="/"
fileElse="${otherLoc}${fileDir}${slash}${fileName}"
swaks -t ${recipient} -s ${server} -h ${ehlo} ${at} ${fileElse}
fi
elif [ ${name} == "n" ]
then
swaks -t ${recipient} -s ${server} -h ${ehlo}
else
echo "Error. Closing the program now."
exit 1
fi
The issue I am having now is when getting an attachment for the noscript, just for the options Downloads and Documents, the noscript gives an error on this line ${downLoc}${fileDownloads} for the Downloads options and, this one fileDoc=${docLoc}${fileDocument} for the Documents option. The only one that works is the first else which you can choose the directory. Any idea guys?
​
Thank you so much for your collaboration and effort.
https://redd.it/10f36rr
@r_bash
reddit
Another noscript
Hi everyone. Hope you all are doing well. I am working on another noscript and I am having an issue. Sharing the noscript below: #!/bin/bash ...
CTRL-R not working?? :x
I got a new system set up and have a really weird behaviour.
- Ubuntu 22.04.1 LTS
- Bash: 5.1.16
When I hit CTRL-R I get:
okay.. So I guess I need a mapping for this (I thought default) hotkey.
I ran
After hitting ctrl-r I get:
I would be really happy about any advice or ideas!
https://redd.it/10f5n9w
@r_bash
I got a new system set up and have a really weird behaviour.
- Ubuntu 22.04.1 LTS
- Bash: 5.1.16
When I hit CTRL-R I get:
bash: bash_execute_unix_command: cannot find keymapokay.. So I guess I need a mapping for this (I thought default) hotkey.
I ran
bind -x '"\C-r": "reverse-search-history"'After hitting ctrl-r I get:
reverse-search-history: command not foundI would be really happy about any advice or ideas!
https://redd.it/10f5n9w
@r_bash
reddit
CTRL-R not working?? :x
I got a new system set up and have a really weird behaviour. - Ubuntu 22.04.1 LTS - Bash: 5.1.16 When I hit CTRL-R I get: `bash:...
Dynamically exclude dirs in the find command
Hi, I have made a small noscript so that given a list of directories it executes find excluding these, the corpus of the noscript is this:
EXCLUDIRS=(dira dirb 'hello word');
if [ ${#EXCLUDIRS[@} -gt 0 ]]; then
declare -a INDXS=("${!EXCLUDIRS@}");
declare -i LASTINDX="${INDXS*: -1}";
for I in "${INDXS@}"; do
EXCLUDIRSTR+="-path ./${EXCLUDIRS$I} -prune";
((I != LASTINDX)) && EXCLUDIRSTR+=' -o ';
done
EXCLUDIRSTR="( $EXCLUDIRSTR ) -o -print";
fi
# shellcheck disable=SC2086
find . $EXCLUDIRSTR;
As you can infer, EXCLUDIRSTR ends up becoming a string of the type:
'(' -path ./dira -prune -path ./dirb -prune -path ./hello word -prune ')'
This works as expected, as long as EXCLUDIRS does not have names with spaces, in this case "hello world" will flag the problem since that space could not be escaped. I have tried several ways, does anyone know what is the correct way for this?
https://redd.it/10fc6af
@r_bash
Hi, I have made a small noscript so that given a list of directories it executes find excluding these, the corpus of the noscript is this:
EXCLUDIRS=(dira dirb 'hello word');
if [ ${#EXCLUDIRS[@} -gt 0 ]]; then
declare -a INDXS=("${!EXCLUDIRS@}");
declare -i LASTINDX="${INDXS*: -1}";
for I in "${INDXS@}"; do
EXCLUDIRSTR+="-path ./${EXCLUDIRS$I} -prune";
((I != LASTINDX)) && EXCLUDIRSTR+=' -o ';
done
EXCLUDIRSTR="( $EXCLUDIRSTR ) -o -print";
fi
# shellcheck disable=SC2086
find . $EXCLUDIRSTR;
As you can infer, EXCLUDIRSTR ends up becoming a string of the type:
'(' -path ./dira -prune -path ./dirb -prune -path ./hello word -prune ')'
This works as expected, as long as EXCLUDIRS does not have names with spaces, in this case "hello world" will flag the problem since that space could not be escaped. I have tried several ways, does anyone know what is the correct way for this?
https://redd.it/10fc6af
@r_bash
reddit
Dynamically exclude dirs in the find command
Hi, I have made a small noscript so that given a list of directories it executes find excluding these, the corpus of the noscript is this: ...
Count frequency of each "alphabet" in file
I can count the frequency of each individual character in a file using
But this prints the frequency of each character. I want to count the frequency of each "alphabet". Could someone suggest a way to do this? (I also want to convert the alphabets to lower case like I am doing in the awk noscript)
https://redd.it/10fc3qu
@r_bash
I can count the frequency of each individual character in a file using
cat $1 | awk -vFS="" '{for(i=1;i<=NF;i++)w[toupper($i)]++}END{for(i in w) print i,w[i]}'.But this prints the frequency of each character. I want to count the frequency of each "alphabet". Could someone suggest a way to do this? (I also want to convert the alphabets to lower case like I am doing in the awk noscript)
https://redd.it/10fc3qu
@r_bash
reddit
Count frequency of each "alphabet" in file
I can count the frequency of each individual character in a file using `cat $1 | awk -vFS="" '{for(i=1;i<=NF;i++)w[toupper($i)]++}END{for(i in w)...
noscript windows template creation with packer
writing a bash noscript to automate the deployment of a packer windows template. I am using RHEL and have a few challenges and would love to get some help please. I have 2 passwords i would like to encrypt so that it does not show up as plain text. I also need to sometimes run the manual process several times as it sometimes fails to run.
I have all the files in my pwd and the below process is all i am needing in a bash noscript
$ export PKR_VAR_vsphere_password=*******
$ export PKR_VAR_winadmin_password=******
packer init .
packer validate .
paker build .
https://redd.it/10fgjw8
@r_bash
writing a bash noscript to automate the deployment of a packer windows template. I am using RHEL and have a few challenges and would love to get some help please. I have 2 passwords i would like to encrypt so that it does not show up as plain text. I also need to sometimes run the manual process several times as it sometimes fails to run.
I have all the files in my pwd and the below process is all i am needing in a bash noscript
$ export PKR_VAR_vsphere_password=*******
$ export PKR_VAR_winadmin_password=******
packer init .
packer validate .
paker build .
https://redd.it/10fgjw8
@r_bash
reddit
noscript windows template creation with packer
writing a bash noscript to automate the deployment of a packer windows template. I am using RHEL and have a few challenges and would love to get...
Auto-generate folders and convert files!
Hello,
I am trying to create a bash noscript that converts h.265 to h.264 and I would like for it to loop through each folder, convert all mkv files and then in another folder create an identical folder with the converted mkv. Essentially if there's a show with many seasons I want it to loop through each season then store the converted file in another folder with the folder name being the season it came from and so on.
Btw I'm newbie :D
Here's what I'm currently doing:
for i in *.mkv;
do name=`echo "$i" | cut -d'.' -f1`
echo "$name"
ffmpeg -i "$i" -map 0 -c:v libx264 -crf 18 -c:a copy rest1/"${name}.mkv"
done
What I'm thinking about: (this is mainly pseudo code)
for i in */;
(creates a folder named the same)
do
for i in *.mkv;
do name=`echo "$i" | cut -d'.' -f1`
echo "$name"
ffmpeg -i "$i" -map 0 -c:v libx264 -crf 18 -c:a copy ${foldernamehere?}/"${name}.mkv"
done
done
Thank you!
https://redd.it/10fn1if
@r_bash
Hello,
I am trying to create a bash noscript that converts h.265 to h.264 and I would like for it to loop through each folder, convert all mkv files and then in another folder create an identical folder with the converted mkv. Essentially if there's a show with many seasons I want it to loop through each season then store the converted file in another folder with the folder name being the season it came from and so on.
Btw I'm newbie :D
Here's what I'm currently doing:
for i in *.mkv;
do name=`echo "$i" | cut -d'.' -f1`
echo "$name"
ffmpeg -i "$i" -map 0 -c:v libx264 -crf 18 -c:a copy rest1/"${name}.mkv"
done
What I'm thinking about: (this is mainly pseudo code)
for i in */;
(creates a folder named the same)
do
for i in *.mkv;
do name=`echo "$i" | cut -d'.' -f1`
echo "$name"
ffmpeg -i "$i" -map 0 -c:v libx264 -crf 18 -c:a copy ${foldernamehere?}/"${name}.mkv"
done
done
Thank you!
https://redd.it/10fn1if
@r_bash
reddit
Auto-generate folders and convert files!
Hello, I am trying to create a bash noscript that converts h.265 to h.264 and I would like for it to loop through each folder, convert all mkv...
Replace IPTables Rule Based on Rule Specification
In a noscript I have the specification of an iptable rule (like what would be used with the "iptable -A" command) that already exists and I need to replace it. Unfortunately the "iptables -R" command expects a rule number not a rule specification. Is there a way to get the rule number of a rule based on its specification? Or is there some other approach to take to replace a rule if all you have is its specification in a noscript?
https://redd.it/10g7f9b
@r_bash
In a noscript I have the specification of an iptable rule (like what would be used with the "iptable -A" command) that already exists and I need to replace it. Unfortunately the "iptables -R" command expects a rule number not a rule specification. Is there a way to get the rule number of a rule based on its specification? Or is there some other approach to take to replace a rule if all you have is its specification in a noscript?
https://redd.it/10g7f9b
@r_bash
reddit
Replace IPTables Rule Based on Rule Specification
In a noscript I have the specification of an iptable rule (like what would be used with the "iptable -A" command) that already exists and I need to...
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