I get errors in if statement "[: : integer expression expected"
I'm trying to write simple code that notifies me when battery is low. Here's my code
#!/bin/bash
# maximal energy in battery
enf0=$(cat /sys/class/power_supply/BAT0/energy_full)
# notify at these levels
btlow=30
bthigh=90
# check every n seconds
time=30
while [ 1 ]
do
# current energy, charging/discharging, energy level in %
enc=$(cat /sys/class/power_supply/BAT0/energy_now) ;
state=$(cat /sys/class/power_supply/BAT0/status) ;
lvl=$(echo "scale=2; $enc * 100 / $enf" | bc) ;
if [ $lvl -lt $btlow ] && [ "$state" == 'Discharging' ]
then
notify-send "Low battery" "Battery level: $lvl%"
fi
sleep $time
done
but when I run it I get error `line 25: [: -lt: unary operator expected`, I read [this](https://stackoverflow.com/questions/50349389/shell-noscript-lt-unary-operator-expected) but when I change this line to `if [ "$lvl" -lt "$btlow" ] && [ "$state" == 'Discharging' ]` then I get different error `line 25: [: : integer expression expected`
https://redd.it/10trm1l
@r_bash
I'm trying to write simple code that notifies me when battery is low. Here's my code
#!/bin/bash
# maximal energy in battery
enf0=$(cat /sys/class/power_supply/BAT0/energy_full)
# notify at these levels
btlow=30
bthigh=90
# check every n seconds
time=30
while [ 1 ]
do
# current energy, charging/discharging, energy level in %
enc=$(cat /sys/class/power_supply/BAT0/energy_now) ;
state=$(cat /sys/class/power_supply/BAT0/status) ;
lvl=$(echo "scale=2; $enc * 100 / $enf" | bc) ;
if [ $lvl -lt $btlow ] && [ "$state" == 'Discharging' ]
then
notify-send "Low battery" "Battery level: $lvl%"
fi
sleep $time
done
but when I run it I get error `line 25: [: -lt: unary operator expected`, I read [this](https://stackoverflow.com/questions/50349389/shell-noscript-lt-unary-operator-expected) but when I change this line to `if [ "$lvl" -lt "$btlow" ] && [ "$state" == 'Discharging' ]` then I get different error `line 25: [: : integer expression expected`
https://redd.it/10trm1l
@r_bash
Stack Overflow
Shell Script - [: -lt: unary operator expected
#!/bin/bash
#ps -aux | grep abcd > /home/test1.txt
var= grep -o -i abcd /home/test1.txt | wc -l
threshold=15
if [ $var -lt $threshold ]; then
echo "One of the service is down on $HOSTNAME" >m...
#ps -aux | grep abcd > /home/test1.txt
var= grep -o -i abcd /home/test1.txt | wc -l
threshold=15
if [ $var -lt $threshold ]; then
echo "One of the service is down on $HOSTNAME" >m...
cp: no such file or directory
Hi all,
I'm using FreeBSD and trying to migrate my jails from iocage to bastille. Really not familiar with bash so figured I would try and noscript it rather than do it manually as a learning exercise.
On the cp command below I get the error:
cp: /tank/iocage/images/db_2023-02-05.*: No such file or directory
Here is the full noscript. I would appreciate any help.
​
#!/usr/bin/bash
jails=$(/usr/local/bin/iocage list -qh | awk '{print $1}')
today=`date "+%Y-%m-%d"`
for jail in ${jails[@]}; do
filename=$jail
filename+="_"
filename+="$today"
iocage stop $jail
iocage export $jail
iocage set boot=0 $jail
cp "/tank/iocage/images/$filename.*" /usr/local/bastille/backups/
bastille import "$filename.zip"
done
https://redd.it/10u8qgq
@r_bash
Hi all,
I'm using FreeBSD and trying to migrate my jails from iocage to bastille. Really not familiar with bash so figured I would try and noscript it rather than do it manually as a learning exercise.
On the cp command below I get the error:
cp: /tank/iocage/images/db_2023-02-05.*: No such file or directory
Here is the full noscript. I would appreciate any help.
​
#!/usr/bin/bash
jails=$(/usr/local/bin/iocage list -qh | awk '{print $1}')
today=`date "+%Y-%m-%d"`
for jail in ${jails[@]}; do
filename=$jail
filename+="_"
filename+="$today"
iocage stop $jail
iocage export $jail
iocage set boot=0 $jail
cp "/tank/iocage/images/$filename.*" /usr/local/bastille/backups/
bastille import "$filename.zip"
done
https://redd.it/10u8qgq
@r_bash
Reddit
r/bash - cp: no such file or directory
Posted in the bash community.
Ask question from bash shell and get tailored documentation response - with pretty printing
https://redd.it/10uh74l
@r_bash
https://redd.it/10uh74l
@r_bash
Reddit
r/bash - Ask question from bash shell and get tailored documentation response - with pretty printing
Posted in the bash community.
Total Duration of YouTube Playlist from Bash Terminal
https://blog.akamhy.me/blog/YouTube-Video-Playlist-Length-From-Bash-Terminal/
https://redd.it/10uj2tp
@r_bash
https://blog.akamhy.me/blog/YouTube-Video-Playlist-Length-From-Bash-Terminal/
https://redd.it/10uj2tp
@r_bash
Reddit
r/bash - Total Duration of YouTube Playlist from Bash Terminal
Posted in the bash community.
I keep getting this error bash: venv/bin/activate: No such file or directory
Following this here on my Git Bash:
https://github.com/openai/openai-quickstart-python
I am at Step 4 where I input:
$ python -m venv venv
Nothing happens. When I type this, the error message in the noscript:
$ . venv/bin/activate
I tried following this guidance, but still no luck.
https://github.com/addok/addok/issues/553
What am I doing wrong here?
https://redd.it/10uh74p
@r_bash
Following this here on my Git Bash:
https://github.com/openai/openai-quickstart-python
I am at Step 4 where I input:
$ python -m venv venv
Nothing happens. When I type this, the error message in the noscript:
$ . venv/bin/activate
I tried following this guidance, but still no luck.
https://github.com/addok/addok/issues/553
What am I doing wrong here?
https://redd.it/10uh74p
@r_bash
GitHub
GitHub - openai/openai-quickstart-python: Python example app from the OpenAI API quickstart tutorial
Python example app from the OpenAI API quickstart tutorial - openai/openai-quickstart-python
A bash noscript that takes all the files inside a folder recursively and then create a csv with the filenames and two columns called typenoscript and javanoscript and checkmark them depending on their extension js or tsx?
A bash noscript that takes all the files inside a folder recursively and then create a csv with the filenames and two columns called typenoscript and javanoscript and checkmark them depending on their extension js or tsx?
https://redd.it/10uwro2
@r_bash
A bash noscript that takes all the files inside a folder recursively and then create a csv with the filenames and two columns called typenoscript and javanoscript and checkmark them depending on their extension js or tsx?
https://redd.it/10uwro2
@r_bash
Reddit
r/bash on Reddit
A bash noscript that takes all the files inside a folder recursively and then create a csv with the filenames and two columns called typenoscript and javanoscript and checkmark them depending on their extension js or tsx?
Should Ulfnic stop using UpperCamel?
Asking for opinions if I should drop UpperCamel for snake_case.
If writing BASH was just about serving myself or following the herd i'd have my answer but here we are... feeling lucky I have people I can ask.
Harsh criticism greatly appreciated.
### Context
I want to start contributing my projects to the BASH ecosystem.
- I'd like my noscripts to useful for learning.
- I'd like people to be able to take pieces of my noscripts for their own projects or use them as a whole.
- Some are source-able meaning some syntax will mix into other people's noscripts (function calls/variable assignment).
- It'll be part of my resume so it'll affect my hire-ability. To what degree i'm not sure as BASH tends be treated as a supplementary language and i'm pretty flexible.
### UpperCamel vs snake_case
Why I think UpperCamel is better:
- It doesn't tread on filename or ENVIRONMENT namespace for both single and multi-word names (with very rare exceptions).
- It doesn't tread on "normal" BASH syntax like snake_case if sourced by someone else reducing likelihood of error and annoyance.
- It makes variables and functions stand out as they don't look like executables.
- Denoscriptive names are shorter because they don't need readability separators.
- Generally easier on people newer to BASH because of the above (imho, mileage may vary).
Why I think snake_case is better:
- It's used by the vast majority of BASH devs so syntax doesn't need to be re-written if code's being merged with other projects reducing likelihood of error and annoyance.
- It doesn't tread on ENVIRONMENT namespace.
- It mostly doesn't tread on multi-word filename namespace
Not sure:
- UpperCamel is easier? harder? for people to read who've only been exposed to snake_case/UPPERCASE BASH.
Thank you for your feedback,
https://redd.it/10v3ol4
@r_bash
Asking for opinions if I should drop UpperCamel for snake_case.
If writing BASH was just about serving myself or following the herd i'd have my answer but here we are... feeling lucky I have people I can ask.
Harsh criticism greatly appreciated.
### Context
I want to start contributing my projects to the BASH ecosystem.
- I'd like my noscripts to useful for learning.
- I'd like people to be able to take pieces of my noscripts for their own projects or use them as a whole.
- Some are source-able meaning some syntax will mix into other people's noscripts (function calls/variable assignment).
- It'll be part of my resume so it'll affect my hire-ability. To what degree i'm not sure as BASH tends be treated as a supplementary language and i'm pretty flexible.
### UpperCamel vs snake_case
Why I think UpperCamel is better:
- It doesn't tread on filename or ENVIRONMENT namespace for both single and multi-word names (with very rare exceptions).
- It doesn't tread on "normal" BASH syntax like snake_case if sourced by someone else reducing likelihood of error and annoyance.
- It makes variables and functions stand out as they don't look like executables.
- Denoscriptive names are shorter because they don't need readability separators.
- Generally easier on people newer to BASH because of the above (imho, mileage may vary).
Why I think snake_case is better:
- It's used by the vast majority of BASH devs so syntax doesn't need to be re-written if code's being merged with other projects reducing likelihood of error and annoyance.
- It doesn't tread on ENVIRONMENT namespace.
- It mostly doesn't tread on multi-word filename namespace
Not sure:
- UpperCamel is easier? harder? for people to read who've only been exposed to snake_case/UPPERCASE BASH.
Thank you for your feedback,
https://redd.it/10v3ol4
@r_bash
Reddit
r/bash on Reddit: Should Ulfnic stop using UpperCamel?
Posted by u/Ulfnic - No votes and no comments
Why the second loop is not getting executed in the shell?
n=1
while (( $n <= 10 ))
do
echo "$n"
((n++))
sleep 0.5
done
echo
while (( $n <= 10 ))
do
echo "$n"
((++n))
sleep 0.5
done
#
https://redd.it/10v3ndv
@r_bash
n=1
while (( $n <= 10 ))
do
echo "$n"
((n++))
sleep 0.5
done
echo
while (( $n <= 10 ))
do
echo "$n"
((++n))
sleep 0.5
done
#
https://redd.it/10v3ndv
@r_bash
Reddit
r/bash - Why the second loop is not getting executed in the shell?
Posted in the bash community.
A nice tool to render pretty markdown in the terminal
Pretty Markdown rendering in the Terminal:
https://www.youtube.com/watch?v=h9JJjyiHOAw
https://redd.it/10v5l7g
@r_bash
Pretty Markdown rendering in the Terminal:
https://www.youtube.com/watch?v=h9JJjyiHOAw
https://redd.it/10v5l7g
@r_bash
YouTube
The Prettiest Markdown rendering on the CLI!
As a developer, you probably have multiple interactions with Markdown on a weekly basis.
This package is very helpful as it allows you to render beautified Markdown directly in your terminal session.
We're also available on:
- Twitter: https://www.t…
This package is very helpful as it allows you to render beautified Markdown directly in your terminal session.
We're also available on:
- Twitter: https://www.t…
Solution to log bash history
Hello,
I'm currently in need of session logs with timestamp and additional metadata from a bash session Input and Output of commands run in bash terminal but currently i found that "tmux logging" logs only a screen of the pane and can't be manipulated very efficiently, i also tried implementing "tlog" but apparently it only works on centOS
Any idea on how to implement such a solution?
in the end i need to have a json file with the input, output, path, user and some other data
thank you !
https://redd.it/10v6hv3
@r_bash
Hello,
I'm currently in need of session logs with timestamp and additional metadata from a bash session Input and Output of commands run in bash terminal but currently i found that "tmux logging" logs only a screen of the pane and can't be manipulated very efficiently, i also tried implementing "tlog" but apparently it only works on centOS
Any idea on how to implement such a solution?
in the end i need to have a json file with the input, output, path, user and some other data
thank you !
https://redd.it/10v6hv3
@r_bash
Reddit
r/bash - Solution to log bash history
Posted in the bash community.
How to run a background noscript when a user logs in?
I have a bash noscript I need to run in the background on macOS. I want it to launch automatically when a user logs in. I tried all approaches that I could find and nothing worked as expected.
The closest solution was a LaunchDaemon. However, I need my noscript to be located and to have access to "\~/Downloads" and LaunchDaemon is unable to do that :(. If you try to run a noscript from "\~/Downloads" it will fail with 126 or 129 error (I don't remember). If you put it somewhere else and try to access "\~/Downloads" it will fail.
I also tried to create an Automator app and add it to "Login Items", but it looks like it starts my noscript and kills it immediately, I don't see it running in the background. My noscript is launching `fswatch` and observes a file all the time.
I even tried adding my noscript using `crontab -e` with "@reboot /my\_noscript", but it doesn't work either. It looks like it doesn't launch at all.
Any ideas? My main requirements are:
* operating system: macOS Ventura or lower
* the noscript will be running in the background after each login
* the noscript is located in "\~/Downloads"
* the noscript has access to "\~/Downloads"
* the noscript has access to packages installed via Homebrew for the current user
https://redd.it/10vc5gw
@r_bash
I have a bash noscript I need to run in the background on macOS. I want it to launch automatically when a user logs in. I tried all approaches that I could find and nothing worked as expected.
The closest solution was a LaunchDaemon. However, I need my noscript to be located and to have access to "\~/Downloads" and LaunchDaemon is unable to do that :(. If you try to run a noscript from "\~/Downloads" it will fail with 126 or 129 error (I don't remember). If you put it somewhere else and try to access "\~/Downloads" it will fail.
I also tried to create an Automator app and add it to "Login Items", but it looks like it starts my noscript and kills it immediately, I don't see it running in the background. My noscript is launching `fswatch` and observes a file all the time.
I even tried adding my noscript using `crontab -e` with "@reboot /my\_noscript", but it doesn't work either. It looks like it doesn't launch at all.
Any ideas? My main requirements are:
* operating system: macOS Ventura or lower
* the noscript will be running in the background after each login
* the noscript is located in "\~/Downloads"
* the noscript has access to "\~/Downloads"
* the noscript has access to packages installed via Homebrew for the current user
https://redd.it/10vc5gw
@r_bash
Reddit
r/bash on Reddit: How to run a background noscript when a user logs in?
Posted by u/john_snow_968 - No votes and 5 comments
How do I synchronize threads?
These ideas didn't work
#!/bin/bash
stop=0
# (for ((i=0 ; i<10 ; i++)) ; do echo $i"/10" ; sleep $i ; done ; stop=1 ; echo stop="$stop" ) & # Doesn't work
# for ((i=0 ; i<10 ; i++)) ; do echo $i"/10" ; sleep $i ; done ; (( stop++ )) ; echo stop="$stop" & # Doesn't work
for ((i=0 ; i<10 ; i++)) ; do echo $i"/10" ; sleep $i ; done && stop=1 && echo stop="$stop" & # Doesn't work
echo waiting
while (( stop==0 )) ; do echo "Waits stop=$stop" ; sleep 5 ; done
echo Done :\)
https://redd.it/10vjmla
@r_bash
These ideas didn't work
#!/bin/bash
stop=0
# (for ((i=0 ; i<10 ; i++)) ; do echo $i"/10" ; sleep $i ; done ; stop=1 ; echo stop="$stop" ) & # Doesn't work
# for ((i=0 ; i<10 ; i++)) ; do echo $i"/10" ; sleep $i ; done ; (( stop++ )) ; echo stop="$stop" & # Doesn't work
for ((i=0 ; i<10 ; i++)) ; do echo $i"/10" ; sleep $i ; done && stop=1 && echo stop="$stop" & # Doesn't work
echo waiting
while (( stop==0 )) ; do echo "Waits stop=$stop" ; sleep 5 ; done
echo Done :\)
https://redd.it/10vjmla
@r_bash
Reddit
r/bash - How do I synchronize threads?
Posted in the bash community.
Is there a repository with snippets to manipulate csv data and create them from the data inside the file system (folders and folder content and file extensions)?
Just trying to write some useful noscript for internal tracking for myself to get better at bash, because the Udemy tutorials I watch goes from one ear and goes out to the other.
https://redd.it/10vl9z9
@r_bash
Just trying to write some useful noscript for internal tracking for myself to get better at bash, because the Udemy tutorials I watch goes from one ear and goes out to the other.
https://redd.it/10vl9z9
@r_bash
Reddit
r/bash - Is there a repository with snippets to manipulate csv data and create them from the data inside the file system (folders…
Posted in the bash community.
Minimal setup for shellcheck as a compiler in Vim for linting bash noscripts.
Hello.
This is the most minimal setup I wanted, because I don't have time to fiddle with this, and I have a setup for quickfix lists, with keyboard shortcuts I remember.
I run 9.0, but there is only 8.x code in the files.
So, I have an sh.vim that I have dropped in `~/.vim/ftplugin` it`s below:
" Vim-licence (c) 2023 McUsr
" Miniscule shellcheck setup
" you :copen the quick fix list however you open the quickfix list!
compiler shellcheck
nnoremap <buffer> <F9> :silent exe "make %:p" <bar> redraw!<CR>
And then there is the sh.vim file in the `~/.vim/compiler` folder file below:
" Vim-licence (c) 2023 McUsr
" Miniscule shellcheck setup
" you :copen the quick fix list however you open the quickfix list!
"
if exists("current_compiler")
finish
endif
let current_compiler = "shellcheck"
CompilerSet makeprg=shellcheck\ -f\ gcc\ \"%:p\"
CompilerSet errorformat=
\ '%f:%l:%c: %trror: %m,' .
\ '%f:%l:%c: %tarning: %m,' .
\ '%I%f:%l:%c: note: %m'
And that is pretty much all there is to it, after I dropped the files in their respective folders I now hit F9 to lint a shellnoscript in the active window.
I hit `\co` to open the `quick fix list`, and then I can jump to the error messages.
FYI. I nicked the format string and the reload-guard from [here](https://github.com/itspriddle/vim-shellcheck).
Enjoy, if you aren't set up already.
https://redd.it/10vmjcp
@r_bash
Hello.
This is the most minimal setup I wanted, because I don't have time to fiddle with this, and I have a setup for quickfix lists, with keyboard shortcuts I remember.
I run 9.0, but there is only 8.x code in the files.
So, I have an sh.vim that I have dropped in `~/.vim/ftplugin` it`s below:
" Vim-licence (c) 2023 McUsr
" Miniscule shellcheck setup
" you :copen the quick fix list however you open the quickfix list!
compiler shellcheck
nnoremap <buffer> <F9> :silent exe "make %:p" <bar> redraw!<CR>
And then there is the sh.vim file in the `~/.vim/compiler` folder file below:
" Vim-licence (c) 2023 McUsr
" Miniscule shellcheck setup
" you :copen the quick fix list however you open the quickfix list!
"
if exists("current_compiler")
finish
endif
let current_compiler = "shellcheck"
CompilerSet makeprg=shellcheck\ -f\ gcc\ \"%:p\"
CompilerSet errorformat=
\ '%f:%l:%c: %trror: %m,' .
\ '%f:%l:%c: %tarning: %m,' .
\ '%I%f:%l:%c: note: %m'
And that is pretty much all there is to it, after I dropped the files in their respective folders I now hit F9 to lint a shellnoscript in the active window.
I hit `\co` to open the `quick fix list`, and then I can jump to the error messages.
FYI. I nicked the format string and the reload-guard from [here](https://github.com/itspriddle/vim-shellcheck).
Enjoy, if you aren't set up already.
https://redd.it/10vmjcp
@r_bash
GitHub
GitHub - itspriddle/vim-shellcheck: Vim wrapper for ShellCheck, a static analysis tool for shell noscripts.
Vim wrapper for ShellCheck, a static analysis tool for shell noscripts. - itspriddle/vim-shellcheck
why from a function in .zshrc i can't process files in another folder ?
I have a noscript that use [Swaks](https://www.jetmore.org/john/code/swaks/) i try to be able to run it from a simple command in my terminal without having to go to the right folder and from their open terminal and run the noscript.
cd .noscript
cd swaks
sh email.sh
I made this function in my .ZSHRC
​
function email {
zsh $HOME/.noscripts/SWAKS/email.sh
}
Program run, but the program doesn't process the file **mod.html**
​
​
#!/bin/bash
# encoding: UTF-8
while true; do
echo "give email adress"
read -r email
echo "PRICE:"
read -r prix
email_regex="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
if [[ $email =~ $email_regex ]]; then
cp template.html mod.html
echo "Adresse email valid."
if [ -z "$prix" ]; then
sd ppprice " " mod.html
else
declare -i prix
if [[ "$prix" -gt 350 && "$prix" -lt 1500 ]]; then
sd ppprice "the price of this is $prix€" mod.html
else
clear
echo "PRIX INCORECT POUR UNE VENTE";
rm mod.html;
exit 1
fi
fi
else
clear
echo "bad email";
exit 1
fi
swaks --body @mod.html -t "$email" --add-header "MIME:Version 1.0" --add-header "Content-Type: text/html" --h-Subject "buy my product" --h-From: '" my name" <xxxxx@gmail.com>' -s smtp.gmail.com:587 -tls -au xxxxxx@gmail.com -ap ejixxxxxxxlelinp -f xxxxxxx@gmail.com --tls-protocol tlsv1_3
clear
rm mod.html;
done
​
https://preview.redd.it/8zjt7qg6tnga1.png?width=315&format=png&auto=webp&v=enabled&s=dcfda9f7d80e13e2068e1fa6dbe69007bce7980c
https://redd.it/10vmzpj
@r_bash
I have a noscript that use [Swaks](https://www.jetmore.org/john/code/swaks/) i try to be able to run it from a simple command in my terminal without having to go to the right folder and from their open terminal and run the noscript.
cd .noscript
cd swaks
sh email.sh
I made this function in my .ZSHRC
​
function email {
zsh $HOME/.noscripts/SWAKS/email.sh
}
Program run, but the program doesn't process the file **mod.html**
​
​
#!/bin/bash
# encoding: UTF-8
while true; do
echo "give email adress"
read -r email
echo "PRICE:"
read -r prix
email_regex="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
if [[ $email =~ $email_regex ]]; then
cp template.html mod.html
echo "Adresse email valid."
if [ -z "$prix" ]; then
sd ppprice " " mod.html
else
declare -i prix
if [[ "$prix" -gt 350 && "$prix" -lt 1500 ]]; then
sd ppprice "the price of this is $prix€" mod.html
else
clear
echo "PRIX INCORECT POUR UNE VENTE";
rm mod.html;
exit 1
fi
fi
else
clear
echo "bad email";
exit 1
fi
swaks --body @mod.html -t "$email" --add-header "MIME:Version 1.0" --add-header "Content-Type: text/html" --h-Subject "buy my product" --h-From: '" my name" <xxxxx@gmail.com>' -s smtp.gmail.com:587 -tls -au xxxxxx@gmail.com -ap ejixxxxxxxlelinp -f xxxxxxx@gmail.com --tls-protocol tlsv1_3
clear
rm mod.html;
done
​
https://preview.redd.it/8zjt7qg6tnga1.png?width=315&format=png&auto=webp&v=enabled&s=dcfda9f7d80e13e2068e1fa6dbe69007bce7980c
https://redd.it/10vmzpj
@r_bash
oh ..what a so many variety of 'output' bash noscript have to have?
i know there's visible output in the terminal and there some others are hidden while doing it's process.
my goal 'straight question' is : i need to export whatever is the bash noscript is writing to a text file , what ever kind of out put is happening 'or not' i want it to be exported to a text file, then after use same noscript again it creates A NEW text file to save those logs OR in same old text file but without wiping the old logs , well ..should i study those standard outputs or someone just tell me how things going ?
what sort of syntax should i add to the noscript to save whatever output happened and write it to specific text file into specific directory ? if someone have time explain to me please . that was my real question for real people .
,if my question doesn't seems cool to you, hold on please don't rush to be a reason for infection of the downvote button syndrome here the question you will like bro. what types of bash outputs and how to manage which is to write and be visible and which to hide if needed 'in case those outputs not needed' thanks in advance .
https://redd.it/10vr5gk
@r_bash
i know there's visible output in the terminal and there some others are hidden while doing it's process.
my goal 'straight question' is : i need to export whatever is the bash noscript is writing to a text file , what ever kind of out put is happening 'or not' i want it to be exported to a text file, then after use same noscript again it creates A NEW text file to save those logs OR in same old text file but without wiping the old logs , well ..should i study those standard outputs or someone just tell me how things going ?
what sort of syntax should i add to the noscript to save whatever output happened and write it to specific text file into specific directory ? if someone have time explain to me please . that was my real question for real people .
,if my question doesn't seems cool to you, hold on please don't rush to be a reason for infection of the downvote button syndrome here the question you will like bro. what types of bash outputs and how to manage which is to write and be visible and which to hide if needed 'in case those outputs not needed' thanks in advance .
https://redd.it/10vr5gk
@r_bash
Reddit
r/bash on Reddit
oh ..what a so many variety of 'output' bash scrip... - No votes and no comments
How would you fuzzy find a file then open it in your editor?
I have a directory with a large number of files (a second brain). I often want to find the full path to a file, then open it with an editor (say vi). Normal, linear tab completion of the path is useless because a) the filenames start with meaningless dates and b) I want to fuzzy search for parts in the middle of the filename because I can't remember how I named each file.
I want to do this from the CLI only, not e.g. from within a full vim or emacs setup, because I'm doing it on Android in Termux and I don't want to set all that up. So basic bash stuff preferred. But some functions or aliases for a .bashrc are on the table.
I don't know a quick way to do this. How would you?
Is there another place you recommend that I post this? Is there a google search that could have led me to a solid answer?
https://redd.it/10vwf1m
@r_bash
I have a directory with a large number of files (a second brain). I often want to find the full path to a file, then open it with an editor (say vi). Normal, linear tab completion of the path is useless because a) the filenames start with meaningless dates and b) I want to fuzzy search for parts in the middle of the filename because I can't remember how I named each file.
I want to do this from the CLI only, not e.g. from within a full vim or emacs setup, because I'm doing it on Android in Termux and I don't want to set all that up. So basic bash stuff preferred. But some functions or aliases for a .bashrc are on the table.
I don't know a quick way to do this. How would you?
Is there another place you recommend that I post this? Is there a google search that could have led me to a solid answer?
https://redd.it/10vwf1m
@r_bash
Reddit
r/bash - How would you fuzzy find a file then open it in your editor?
Posted in the bash community.
Using expect to execute remote curl command with ssh
Hi guys, i do have following situation:
I am running a Bash-Script on a Linux Machine. From this Linux Machine i need to ssh to another Server on which i want to execute two curl-Commands. Those curl-commands will be aiming a machine which has no public ip-address, and the private ip is only known to the host i want to run the curl-command on.
I detected "expect" for this. But either i don't know how to use it properly, or it does not even work the way i want. I need two curl commands. One will receive a token which i have to use in the second curl.
I tried it the way i would expect it to work in shell. Like saving with
token=$(curl ...)
the token into a variable, and use it afterwards in the second token commands. I tried this but it didn't work, as it tried to resolve $(curl ...) as a variable which it says is unknown.
What would be the right way to do this?
https://redd.it/10vxcaa
@r_bash
Hi guys, i do have following situation:
I am running a Bash-Script on a Linux Machine. From this Linux Machine i need to ssh to another Server on which i want to execute two curl-Commands. Those curl-commands will be aiming a machine which has no public ip-address, and the private ip is only known to the host i want to run the curl-command on.
I detected "expect" for this. But either i don't know how to use it properly, or it does not even work the way i want. I need two curl commands. One will receive a token which i have to use in the second curl.
I tried it the way i would expect it to work in shell. Like saving with
token=$(curl ...)
the token into a variable, and use it afterwards in the second token commands. I tried this but it didn't work, as it tried to resolve $(curl ...) as a variable which it says is unknown.
What would be the right way to do this?
https://redd.it/10vxcaa
@r_bash
Reddit
r/bash - Using expect to execute remote curl command with ssh
Posted in the bash community.