Random Joke generator
Small bash file to tell a random joke. (100+ available!)
​
\#!/bin/bash
\#mmartin.,29/01/23, Purpose:Print a random joke
awk '
BEGIN{ srand() }
rand() * NR < 1 {
line = $0
}
END { print line }' \~/Documents/VariousTexts/jokes.txt
exit
​
Download from my github
github.com/myklmar/noscripts with jokes.txt file.
https://redd.it/10oc0a4
@r_bash
Small bash file to tell a random joke. (100+ available!)
​
\#!/bin/bash
\#mmartin.,29/01/23, Purpose:Print a random joke
awk '
BEGIN{ srand() }
rand() * NR < 1 {
line = $0
}
END { print line }' \~/Documents/VariousTexts/jokes.txt
exit
​
Download from my github
github.com/myklmar/noscripts with jokes.txt file.
https://redd.it/10oc0a4
@r_bash
GitHub
GitHub - myklmar/noscripts: noscripts, cli tricks,
noscripts, cli tricks, . Contribute to myklmar/noscripts development by creating an account on GitHub.
GitHub - awesome-lists/awesome-bash: A curated list of delightful Bash noscripts and resources.
https://github.com/awesome-lists/awesome-bash
https://redd.it/10ozsm8
@r_bash
https://github.com/awesome-lists/awesome-bash
https://redd.it/10ozsm8
@r_bash
GitHub
GitHub - awesome-lists/awesome-bash: A curated list of delightful Bash noscripts and resources.
A curated list of delightful Bash noscripts and resources. - awesome-lists/awesome-bash
How can I execute bash commands from a string ?
Something like this:
cmd="Hello World! | cat -"
$cmd
https://redd.it/10p316j
@r_bash
Something like this:
cmd="Hello World! | cat -"
$cmd
https://redd.it/10p316j
@r_bash
Reddit
r/bash on Reddit: How can I execute bash commands from a string ?
Posted by u/FinTechno - No votes and no comments
Thank you
I don’t post much but I do lurk around looking to learn. From beginner to expert questions everyone is very helpful. Just wanted to say thank you to the community.
BTW will be cross posting to r/commandline because they are a great community as well.
https://redd.it/10p3tia
@r_bash
I don’t post much but I do lurk around looking to learn. From beginner to expert questions everyone is very helpful. Just wanted to say thank you to the community.
BTW will be cross posting to r/commandline because they are a great community as well.
https://redd.it/10p3tia
@r_bash
Reddit
r/bash - Thank you
Posted in the bash community.
How to filer partial matches that do not end in certain characters
first time posting, forgive me
Basically I want to filter output to go from something like this:
mate-desktop-common
gedit
gedit:i386
to this
mate-desktop-common
gedit:i386
How would I do that?
https://redd.it/10p6duw
@r_bash
first time posting, forgive me
Basically I want to filter output to go from something like this:
mate-desktop-common
gedit
gedit:i386
to this
mate-desktop-common
gedit:i386
How would I do that?
https://redd.it/10p6duw
@r_bash
Reddit
r/bash - How to filer partial matches that do not end in certain characters
Posted in the bash community.
exit terminal without closing the program / headless mode
Hi there!I run this noscript:
The goal is to open weston, which will start waydroid in that window size. Everything works fine, but I'd like to hide or exit the terminal and only show the weston window. (Like headless mode)? How could I achieve this?
https://redd.it/10pd91w
@r_bash
Hi there!I run this noscript:
#! /bin/sh. waydroid session stop weston --width=555 --height=875 -Swayland-droid & WAYLAND_DISPLAY=wayland-droid waydroid show-full-uiThe goal is to open weston, which will start waydroid in that window size. Everything works fine, but I'd like to hide or exit the terminal and only show the weston window. (Like headless mode)? How could I achieve this?
https://redd.it/10pd91w
@r_bash
Reddit
r/bash on Reddit: exit terminal without closing the program / headless mode
Posted by u/crepuscopoli - No votes and no comments
How do you copy the folder structure of a folder and paste it in a new folder?
How do you copy the folder structure of a folder and paste it in a new folder? I have a folder with a lot of subfolders that contains a lot of subfolders, and I would like to copy the folder structure so I don't have to do it manually. Is there any command for this?
https://redd.it/10ppmtr
@r_bash
How do you copy the folder structure of a folder and paste it in a new folder? I have a folder with a lot of subfolders that contains a lot of subfolders, and I would like to copy the folder structure so I don't have to do it manually. Is there any command for this?
https://redd.it/10ppmtr
@r_bash
Reddit
r/bash - How do you copy the folder structure of a folder and paste it in a new folder?
Posted in the bash community.
Print just first lines beginning with "> " via sed doesn't work
Hi! Here is my input file:
#
> Check file types and compare values
> Returns 0 if the condition evaluates to true, 1 if it evaluates to false
> More information: https://www.gnu.org/software/bash/manual/bash.html#index-test
- Test if a given variable [is equal/not equal to the specified string:
Here is my noscript:
#!/usr/bin/env bash
declare file="/home/emilyseville7cfg/Documents/mine/other/cli-pages/common/.btldr"
sed -nE '/^>/ {
h
:denoscription
N
H
/> (Aliases|See also|More information):/! bdenoscription
s/^.*\n//
x
p
Q
}' "$file"
I wanna print just all lines beginning with `> ` but not including `(Aliases|See also|More information):` at the beginning. I expect such lines to be in the pattern buffer at the end of the noscript but surprisingly I get this output:
> Check file types and compare values
> Check file types and compare values
> Returns 0 if the condition evaluates to true, 1 if it evaluates to false
> Check file types and compare values
> Returns 0 if the condition evaluates to true, 1 if it evaluates to false
> More information: https://www.gnu.org/software/bash/manual/bash.html#index-test
Note that hold space should contain `> More information: https://www.gnu.org/software/bash/manual/bash.html#index-test` at the end of the noscript.
My idea was to condense all lines starting with an angle bracket in the pattern space excluding the last one containing `(Aliases|See also|More information):`. What am I missing to implement what I want?
[https://redd.it/10pwd8q
@r_bash
Hi! Here is my input file:
#
> Check file types and compare values
> Returns 0 if the condition evaluates to true, 1 if it evaluates to false
> More information: https://www.gnu.org/software/bash/manual/bash.html#index-test
- Test if a given variable [is equal/not equal to the specified string:
[ "${string value: variable}" {string value: ==|!=} "{string value: string}" ]Here is my noscript:
#!/usr/bin/env bash
declare file="/home/emilyseville7cfg/Documents/mine/other/cli-pages/common/.btldr"
sed -nE '/^>/ {
h
:denoscription
N
H
/> (Aliases|See also|More information):/! bdenoscription
s/^.*\n//
x
p
Q
}' "$file"
I wanna print just all lines beginning with `> ` but not including `(Aliases|See also|More information):` at the beginning. I expect such lines to be in the pattern buffer at the end of the noscript but surprisingly I get this output:
> Check file types and compare values
> Check file types and compare values
> Returns 0 if the condition evaluates to true, 1 if it evaluates to false
> Check file types and compare values
> Returns 0 if the condition evaluates to true, 1 if it evaluates to false
> More information: https://www.gnu.org/software/bash/manual/bash.html#index-test
Note that hold space should contain `> More information: https://www.gnu.org/software/bash/manual/bash.html#index-test` at the end of the noscript.
My idea was to condense all lines starting with an angle bracket in the pattern space excluding the last one containing `(Aliases|See also|More information):`. What am I missing to implement what I want?
[https://redd.it/10pwd8q
@r_bash
www.gnu.org
Bash Features ¶
Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
Can I do -this- using a bash noscript?
I have a fee Lua driver files that use libraries. I need to provide context for any use of these libraries in the file so that all the logic is contained in one file. Can I accomplish that using a bash noscript? All files will be stored locally.
https://redd.it/10qdrc8
@r_bash
I have a fee Lua driver files that use libraries. I need to provide context for any use of these libraries in the file so that all the logic is contained in one file. Can I accomplish that using a bash noscript? All files will be stored locally.
https://redd.it/10qdrc8
@r_bash
Reddit
r/bash - Can I do -this- using a bash noscript?
Posted in the bash community.
Bash noscript to invoke conda environment
I'm trying to write a bash noscript for executing a set of commands to activate my conda env
#!/bin/csh
source ~/.cshrc
module load anaconda3/4.2.0
source <path>/conda.csh
conda activate myenv1
however post the noscript execution, I expect myenv1 to be activated but that fails to happen, why is that? and what can I do to fix it?
https://redd.it/10qn164
@r_bash
I'm trying to write a bash noscript for executing a set of commands to activate my conda env
#!/bin/csh
source ~/.cshrc
module load anaconda3/4.2.0
source <path>/conda.csh
conda activate myenv1
however post the noscript execution, I expect myenv1 to be activated but that fails to happen, why is that? and what can I do to fix it?
https://redd.it/10qn164
@r_bash
Reddit
r/bash - Bash noscript to invoke conda environment
Posted in the bash community.
I can run a program even though it's not in my current directory, and is not found when I use the
I wrote a bash noscript a few weeks ago and could have sworn I put it in my ~/bin/ folder. Yesterday, I wanted to use the noscript but forgot the name of it, so I perused ~/bin/ to refresh my memory. I couldn't find it! So instead, I searched my history to find the name of the noscript. It's not in ~/bin/, so I used
How can I find the location of this noscript? And why isn't it showing up when I try to find it with
https://redd.it/10qwod7
@r_bash
which command. Where the heck is my program??I wrote a bash noscript a few weeks ago and could have sworn I put it in my ~/bin/ folder. Yesterday, I wanted to use the noscript but forgot the name of it, so I perused ~/bin/ to refresh my memory. I couldn't find it! So instead, I searched my history to find the name of the noscript. It's not in ~/bin/, so I used
which <noscript_name> to find it... but nothing was found! I thought that maybe I deleted the noscript by mistake somehow, but then I noticed that when I typed part of the noscript name it would auto-complete with tab. I tried to run it, and it works! But I have no idea where the heck this noscript even is, so that I can update it!How can I find the location of this noscript? And why isn't it showing up when I try to find it with
which?https://redd.it/10qwod7
@r_bash
Reddit
r/bash on Reddit
I can run a program even though it's not in my cur... - No votes and 1 comment
sed modify first ocurrence
Hello, in nginx vhost i need add string in the same line of server_name.
Example:
server {
server_name HERE domain1.com
}
to this I have been able to solve with the following:
​
sed 's/\\bserver_name\\b/& domain2.com/'
Inside the vhost file there are several server_name and I just have to modify the first occurrence I tried with sed '1 s/\\bserver_name\\b/ domain2.com' but it does not work.
Any helps?
https://redd.it/10r37uk
@r_bash
Hello, in nginx vhost i need add string in the same line of server_name.
Example:
server {
server_name HERE domain1.com
}
to this I have been able to solve with the following:
​
sed 's/\\bserver_name\\b/& domain2.com/'
Inside the vhost file there are several server_name and I just have to modify the first occurrence I tried with sed '1 s/\\bserver_name\\b/ domain2.com' but it does not work.
Any helps?
https://redd.it/10r37uk
@r_bash
Reddit
r/bash - sed modify first ocurrence
Posted in the bash community.
How to store multiline string in variable preserving indents and newlines?
Hi,
How do I store a multiline hardcoded string line like
If I write it like e.g.
There appears to be a leading whitespace at each new line after sentence1.
Just for clarity as the string is long, I cannot write
Thanks in advance
https://redd.it/10r85hb
@r_bash
Hi,
How do I store a multiline hardcoded string line like
sentence1\n
sentence2\n
\tsentence3
If I write it like e.g.
var="
sentence1\n
sentence2\n
\tsentence3
"
There appears to be a leading whitespace at each new line after sentence1.
Just for clarity as the string is long, I cannot write
sentence1\nsentence2\n\tsentence3in one line
Thanks in advance
https://redd.it/10r85hb
@r_bash
Reddit
r/bash - How to store multiline string in variable preserving indents and newlines?
Posted in the bash community.
Grep for a string only if it appears in the last field, without removing anything else from the string?
Let's say I'm trying to grep through these:
1 /dir1/dir2/dir3/banana
2 /dir1/dir2/banana/file
3 /dir1/dir2/bananafile
I want to grep for banana, and I want it to return rows 1 and 3 only. Line 2 should not be returned because banana does not appear after the last slash.
I also want the full lines displayed, so chopping the line up with awk would not help.
Anyone have any ideas? I'm sure this is very easy with a regex.
https://redd.it/10rc8so
@r_bash
Let's say I'm trying to grep through these:
1 /dir1/dir2/dir3/banana
2 /dir1/dir2/banana/file
3 /dir1/dir2/bananafile
I want to grep for banana, and I want it to return rows 1 and 3 only. Line 2 should not be returned because banana does not appear after the last slash.
I also want the full lines displayed, so chopping the line up with awk would not help.
Anyone have any ideas? I'm sure this is very easy with a regex.
https://redd.it/10rc8so
@r_bash
Reddit
r/bash - Grep for a string only if it appears in the last field, without removing anything else from the string?
Posted in the bash community.
Is there something with test -v?
I swear I did it right yesterday:
So, I exported a variable
There was no way I managed the test to fire in a noscript like this:
#!/bin/bash
if -v XDG_BIN_HOME ; then
echo It is set
fi
And I did check my spelling several times. I wondered, last night if it was the .sh extension I had on the test noscript:
But, today it worked.
Do any of you have any clue as to what can have caused the malfunctioning. I feel I can't trust
And, I can't understand how the builtin test could have been unset.
https://redd.it/10rrle6
@r_bash
I swear I did it right yesterday:
So, I exported a variable
export XDG_BIN_HOME=$HOME/.local/binThere was no way I managed the test to fire in a noscript like this:
#!/bin/bash
if -v XDG_BIN_HOME ; then
echo It is set
fi
And I did check my spelling several times. I wondered, last night if it was the .sh extension I had on the test noscript:
testv.sh.But, today it worked.
Do any of you have any clue as to what can have caused the malfunctioning. I feel I can't trust
test -v now, and well, the rework from that to if [ x"$XDG_BIN_HOME" = x ] ; then ..., isn't that big, but it is annoying.And, I can't understand how the builtin test could have been unset.
GNU bash, version 5.1.4(1)-release (x86_64-pc-linux-gnu) under tmux 3.1c, inside alacritty 0.12.0-dev (87c38aa9)https://redd.it/10rrle6
@r_bash
Reddit
r/bash - Is there something with test -v?
Posted in the bash community.
bash completion git
Sorry, can't figure out how to crosspost from mobile browser, therefore link to question on r/git here: https://www.reddit.com/r/git/comments/10s1lne/bashcompletionlikegitmainforalias/?utmsource=share&utmmedium=mweb
https://redd.it/10s25a4
@r_bash
Sorry, can't figure out how to crosspost from mobile browser, therefore link to question on r/git here: https://www.reddit.com/r/git/comments/10s1lne/bashcompletionlikegitmainforalias/?utmsource=share&utmmedium=mweb
https://redd.it/10s25a4
@r_bash
Reddit
r/git - bash completion like git main for alias
Posted in the git community.
Calling all awk experts
I'm working on a noscript to handle bulk new user adding. The goal is to have a single noscript that will be portable between our various Linux systems and our BSD systems (bonus points if it also works on Solaris). The code I'm fixing already assumes bash, so that's good.
Linux has newusers, and BSD has useradd -f but the file formats are different, and many of the fields will be left blank (e.g. UID and GID, which are generated by the system). The gecos field is a bit complicated, so it makes it necessary to use awk, instead of something simple like cut. See below:
Input
$ cat sample
mmouse:"Mickey Mouse mmouse@foo.bar", Downtown Office
mmouse1:"Minnie Mouse mmouse1foo.bar", Work from Home
smcduck:"Scrooge McDuck", Corporate
I have no illusions of doing both linux and freebsd in a single awk command, so I've already got an OS Detection function which chooses which version of the awk command to use
The date in the FreeBSD output is generated by
The passwords used here are temporary passwords, and force a change on the first login. I need to preserve them long enough to send an email. For simplicity (and portability), I'm using the following to generate passwords:
Desired output (FreeBSD)
mmouse::::02-02-2023::"Mickey Mouse mmouse@foo.bar", Downtown Office:/home/mmouse:bash:JDF9iQXh
mmouse1::::02-02-2023::"Minnie Mouse mmouse1@foo.bar", Work from Home:/home/mmouse1:bash:ryVDgJ9N
smcduck::::02-02-2023::"Scrooge McDuck ceo@foo.bar", Corporate:/home/smcduck:bash:X9kfz7x0
Desired output (Linux)
mmouse:JDF9iQXh:::"Mickey Mouse mmouse@foo.bar", Downtown Office:/home/mmouse:/bin/bash
mmouse1:ryVDgJ9N:::"Minnie Mouse mmouse1@foo.bar", Work from Home:/home/mmouse1:/bin/bash
smcduck:X9kfz7x0:::"Scrooge McDuck ceo@foo.bar", Corporate:/home/smcduck:/bin/bash
What I have so far
today=$(date +%d-%m-%Y)
# Build the file to the format that FreeBSD expects
#
awk -F':' -v today="${today}" '{print $1"::::"today"::"$2":/home/"$1":bash:password how?"}' input > outputFreeBSD
This works, but without the password, and I can't figure that part out. If I add a system(...) call in the middle of the print statement, it blows up. I have to be able to generate a pass for each user, and preserve the value of that pass so I can email it to the user (using the email address in the gecos, which will no doubt be another headache). I don't want to include it as a static entry in the input file, because I want to have some semblance of security with something that's generated and used only once.
e: I guess as long as the usernamegecoswithpassword file contains the password (until the noscript cleans up after itself at the end), I can pull the username and password fields to send the emails, but I still have to get the password thing figured out.
I'm also okay with doing this as two steps - e.g. one awk to build user:gecos:pass and then another to build the one expected by the system's useradd command.
e2:
For those curious about the OS detection, I shouldn't have been so grandiose - bash is the one who has the detection and I just read that variable
if [ "$OSTYPE" == "linux-gnu"* ]; then
linux
elif [ "$OSTYPE" == "freebsd"* ]; then
freebsd
elif [ "$OSTYPE" == "darwin"* ]; then
echo "go home MacOS, you're drunk"
exit
else
return
fi
https://redd.it/10s60l3
@r_bash
I'm working on a noscript to handle bulk new user adding. The goal is to have a single noscript that will be portable between our various Linux systems and our BSD systems (bonus points if it also works on Solaris). The code I'm fixing already assumes bash, so that's good.
Linux has newusers, and BSD has useradd -f but the file formats are different, and many of the fields will be left blank (e.g. UID and GID, which are generated by the system). The gecos field is a bit complicated, so it makes it necessary to use awk, instead of something simple like cut. See below:
Input
$ cat sample
mmouse:"Mickey Mouse mmouse@foo.bar", Downtown Office
mmouse1:"Minnie Mouse mmouse1foo.bar", Work from Home
smcduck:"Scrooge McDuck", Corporate
I have no illusions of doing both linux and freebsd in a single awk command, so I've already got an OS Detection function which chooses which version of the awk command to use
The date in the FreeBSD output is generated by
date +%d-%m-%YThe passwords used here are temporary passwords, and force a change on the first login. I need to preserve them long enough to send an email. For simplicity (and portability), I'm using the following to generate passwords:
openssl rand -base64 8 | head -c 8Desired output (FreeBSD)
mmouse::::02-02-2023::"Mickey Mouse mmouse@foo.bar", Downtown Office:/home/mmouse:bash:JDF9iQXh
mmouse1::::02-02-2023::"Minnie Mouse mmouse1@foo.bar", Work from Home:/home/mmouse1:bash:ryVDgJ9N
smcduck::::02-02-2023::"Scrooge McDuck ceo@foo.bar", Corporate:/home/smcduck:bash:X9kfz7x0
Desired output (Linux)
mmouse:JDF9iQXh:::"Mickey Mouse mmouse@foo.bar", Downtown Office:/home/mmouse:/bin/bash
mmouse1:ryVDgJ9N:::"Minnie Mouse mmouse1@foo.bar", Work from Home:/home/mmouse1:/bin/bash
smcduck:X9kfz7x0:::"Scrooge McDuck ceo@foo.bar", Corporate:/home/smcduck:/bin/bash
What I have so far
today=$(date +%d-%m-%Y)
# Build the file to the format that FreeBSD expects
#
awk -F':' -v today="${today}" '{print $1"::::"today"::"$2":/home/"$1":bash:password how?"}' input > outputFreeBSD
This works, but without the password, and I can't figure that part out. If I add a system(...) call in the middle of the print statement, it blows up. I have to be able to generate a pass for each user, and preserve the value of that pass so I can email it to the user (using the email address in the gecos, which will no doubt be another headache). I don't want to include it as a static entry in the input file, because I want to have some semblance of security with something that's generated and used only once.
e: I guess as long as the usernamegecoswithpassword file contains the password (until the noscript cleans up after itself at the end), I can pull the username and password fields to send the emails, but I still have to get the password thing figured out.
I'm also okay with doing this as two steps - e.g. one awk to build user:gecos:pass and then another to build the one expected by the system's useradd command.
e2:
For those curious about the OS detection, I shouldn't have been so grandiose - bash is the one who has the detection and I just read that variable
if [ "$OSTYPE" == "linux-gnu"* ]; then
linux
elif [ "$OSTYPE" == "freebsd"* ]; then
freebsd
elif [ "$OSTYPE" == "darwin"* ]; then
echo "go home MacOS, you're drunk"
exit
else
return
fi
https://redd.it/10s60l3
@r_bash
Reddit
r/bash - Calling all awk experts
Posted in the bash community.
Bash output to a csv file is missing header.
Hello folks, I am new to bash, so bear with me.
In our server, I am trying to run a sql command and write the output to a csv file, something like this:
echo "select top 10 * from myTable" | tql >result.csv
This is writing data to the csv file, as expected - but for some reason, it is not writing the column names. How can I get the column names and the data in one csv file?
https://redd.it/10s9nic
@r_bash
Hello folks, I am new to bash, so bear with me.
In our server, I am trying to run a sql command and write the output to a csv file, something like this:
echo "select top 10 * from myTable" | tql >result.csv
This is writing data to the csv file, as expected - but for some reason, it is not writing the column names. How can I get the column names and the data in one csv file?
https://redd.it/10s9nic
@r_bash
Reddit
r/bash on Reddit: Bash output to a csv file is missing header.
Posted by u/pulsarrex - No votes and no comments
Split multiple videos in folder if longer than 30 minutes
Hello,
i have about 450 videos and a few are longer than 30 minutes.
is there any way that a noscript automatically "scan" all videos in the folder and split those, who are longer than 29:59:59 into part1.. part2?
Greetings!
https://redd.it/10sgcd2
@r_bash
Hello,
i have about 450 videos and a few are longer than 30 minutes.
is there any way that a noscript automatically "scan" all videos in the folder and split those, who are longer than 29:59:59 into part1.. part2?
Greetings!
https://redd.it/10sgcd2
@r_bash
Reddit
r/bash - Split multiple videos in folder if longer than 30 minutes
Posted in the bash community.
Difference between separating commands by
Somehow pressing return in a bash terminal session has a gross effect that
I have the following result, reproducible and in multiple projects:
This works consistently:
$ rm -Rf .direnv/ && direnv allow
$ poetry install
Installing dependencies from lock file
Package operations: 23 installs, 0 updates, 0 removals
... much more ...
But none of these do:
$ rm -Rf .direnv/ && direnv allow && poetry install
Errno 2 No such file or directory: 'python'
$ rm -Rf .direnv/ ; direnv allow ; poetry install
Errno 2 No such file or directory: 'python'
$ rm -Rf .direnv/ ; direnv allow ; sleep 10; poetry install
Errno 2 No such file or directory: 'python'
$ cat ./clear.sh
#!/bin/bash
rm -Rf .direnv/ && direnv allow
poetry install
$ ./clear.sh
Errno 2 No such file or directory: 'python'
$ source ./clear.sh
Errno 2 No such file or directory: 'python'
$ bash ./clear.sh
Errno 2 No such file or directory: 'python'
Now
I just wanted to write
Thanks in advance!
https://redd.it/10sj81o
@r_bash
; or && or a new line in a noscript, and pressing return on the command line?Somehow pressing return in a bash terminal session has a gross effect that
; or having a new line in a noscript does not.I have the following result, reproducible and in multiple projects:
This works consistently:
$ rm -Rf .direnv/ && direnv allow
$ poetry install
Installing dependencies from lock file
Package operations: 23 installs, 0 updates, 0 removals
... much more ...
But none of these do:
$ rm -Rf .direnv/ && direnv allow && poetry install
Errno 2 No such file or directory: 'python'
$ rm -Rf .direnv/ ; direnv allow ; poetry install
Errno 2 No such file or directory: 'python'
$ rm -Rf .direnv/ ; direnv allow ; sleep 10; poetry install
Errno 2 No such file or directory: 'python'
$ cat ./clear.sh
#!/bin/bash
rm -Rf .direnv/ && direnv allow
poetry install
$ ./clear.sh
Errno 2 No such file or directory: 'python'
$ source ./clear.sh
Errno 2 No such file or directory: 'python'
$ bash ./clear.sh
Errno 2 No such file or directory: 'python'
Now
direnv is of course doing something fancy with bash behind the scenes to achieve its effects, but how does it "know the difference" between ; or a new line in a noscript, and pressing return in the terminal?I just wanted to write
alias clean='rm -Rf .direnv/ && direnv allow && poetry install', I wasn't trying to cause any trouble ;-), is there some workaround?Thanks in advance!
https://redd.it/10sj81o
@r_bash
Reddit
Difference between separating commands by `;` or `&&` or a new line in a noscript, and pressing return on the command line?
Posted in the bash community.
Trouble adding escape character for {
I have a noscript that I've written to download files via rclone. My noscript goes through the file list and adds escapes to [ and \] without issue. I've recently found out that { and } also cause problems, so I'm trying to add escape characters before those as well. I copied the code that I used for [ and \], and while it worked fine for }, it doesn't work on {. Does anyone know what I could do to make it work?
sed -i 's/\\\]/\\\\&/g' "$LOGFOLDER"/Current.txt # Escape \] - This one works
sed -i 's/\\[/\\\\&/g' "$LOGFOLDER"/Current.txt # Escape [ - This one works
sed -i 's/\\}/\\\\&/g' "$LOGFOLDER"/Current.txt # Escape } - This one works
sed -i 's/\\{/\\\\&/g' "$LOGFOLDER"/Current.txt # Escape { - This one does not work
https://redd.it/10snxpd
@r_bash
I have a noscript that I've written to download files via rclone. My noscript goes through the file list and adds escapes to [ and \] without issue. I've recently found out that { and } also cause problems, so I'm trying to add escape characters before those as well. I copied the code that I used for [ and \], and while it worked fine for }, it doesn't work on {. Does anyone know what I could do to make it work?
sed -i 's/\\\]/\\\\&/g' "$LOGFOLDER"/Current.txt # Escape \] - This one works
sed -i 's/\\[/\\\\&/g' "$LOGFOLDER"/Current.txt # Escape [ - This one works
sed -i 's/\\}/\\\\&/g' "$LOGFOLDER"/Current.txt # Escape } - This one works
sed -i 's/\\{/\\\\&/g' "$LOGFOLDER"/Current.txt # Escape { - This one does not work
https://redd.it/10snxpd
@r_bash
Reddit
Trouble adding escape character for {
Posted in the bash community.