Drop your favorite .bash_profile line and we will create a badass config
https://redd.it/168dzuh
@r_bash
https://redd.it/168dzuh
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
How to send password to redis-cli , perform the login and keep redis-cli open with a bash noscript?
#!/usr/bin/env bash
# Unofficial Bash Strict Mode
set -e
set -E
set -o pipefail
set -u
set -x
IFS=$'\n\t'
# End of Unofficial Bash Strict Mode
host="localhost"
password="somepassword"
port="6379"
db="0"
redis-cli -h "${host}" -p "${port}" -n "${db}"
# HOW TO send AUTH command with password and keep the redis-cli OPEN?
https://redd.it/168rqbs
@r_bash
#!/usr/bin/env bash
# Unofficial Bash Strict Mode
set -e
set -E
set -o pipefail
set -u
set -x
IFS=$'\n\t'
# End of Unofficial Bash Strict Mode
host="localhost"
password="somepassword"
port="6379"
db="0"
redis-cli -h "${host}" -p "${port}" -n "${db}"
# HOW TO send AUTH command with password and keep the redis-cli OPEN?
https://redd.it/168rqbs
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Please tell me why running cat returns contents but running cat within echo or printf statements it says the file doesn't exits
This command works:
docker exec --user root myapp cat admin/password
output:
KMZWaE2r81b(cT5x&(S7Wg7CJ
When I run it like this:
docker exec --user root myapp echo "ADMIN PASSWORD: " && "$(cat admin/password)"
output:
ADMIN PASSWORD:
cat: admin/password: No such file or directory
I attempted with printf as well:
docker exec --user root myapp printf "ADMIN PASSWORD: \"%s\"", "$(cat admin/password)"
output:
cat: admin/password: No such file or directory
At this point I am extremely confused why this is happening.
https://redd.it/1690klv
@r_bash
This command works:
docker exec --user root myapp cat admin/password
output:
KMZWaE2r81b(cT5x&(S7Wg7CJ
When I run it like this:
docker exec --user root myapp echo "ADMIN PASSWORD: " && "$(cat admin/password)"
output:
ADMIN PASSWORD:
cat: admin/password: No such file or directory
I attempted with printf as well:
docker exec --user root myapp printf "ADMIN PASSWORD: \"%s\"", "$(cat admin/password)"
output:
cat: admin/password: No such file or directory
At this point I am extremely confused why this is happening.
https://redd.it/1690klv
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Why is this noscript not working to print the logs between two time duration?
LC_ALL=C awk -v beg=10:00:00 -v end=13:00:00 '
match($0, /[0-2][0-9]:[0-5][0-9]:[0-5][0-9]/) {
t = substr($0, RSTART, 8)
if (t >= end) selected = 0
else if (t >= beg) selected = 1
}
selected'
Why do you think is this not working in some servers, whereas working in some servers?
I invoke it as
bash noscript.sh application.log
https://redd.it/16920u2
@r_bash
LC_ALL=C awk -v beg=10:00:00 -v end=13:00:00 '
match($0, /[0-2][0-9]:[0-5][0-9]:[0-5][0-9]/) {
t = substr($0, RSTART, 8)
if (t >= end) selected = 0
else if (t >= beg) selected = 1
}
selected'
Why do you think is this not working in some servers, whereas working in some servers?
I invoke it as
bash noscript.sh application.log
https://redd.it/16920u2
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
How do I find the field names for the output of a command?
Something easy like ls -l, it outputs data but the column name isn't displayed. I looked in man ls but there isn't any information either.
https://redd.it/16939ml
@r_bash
Something easy like ls -l, it outputs data but the column name isn't displayed. I looked in man ls but there isn't any information either.
https://redd.it/16939ml
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Why do I have to escape space or '&' in a character class?
why this is wrong
What special meaning these two have in a character class (or shell) that I have to escape them?
I know '&' is bitwise AND but I mean shell knows this is a character class, it doesn't make sense for the shell to interpret '&' as bitwise AND in a character class. Have no idea about the space though.
https://redd.it/1694sc0
@r_bash
why this is wrong
[ -z] but this [\ -z] is right? same goes for the case of '&'.What special meaning these two have in a character class (or shell) that I have to escape them?
I know '&' is bitwise AND but I mean shell knows this is a character class, it doesn't make sense for the shell to interpret '&' as bitwise AND in a character class. Have no idea about the space though.
https://redd.it/1694sc0
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Is requesting a sudo password via dialog this way unsafe?
I'm practicing my bash noscripting and want to request the user's sudo password using
As I'm new at this I would also appreciate any other suggestions/tips/comments!
Github link to current noscript here
​
I realize that sudo already has its own way of requesting the password, this is just for looks and practice. You could also just run the whole noscript as sudo but that's not the point of this exercise for me.
https://redd.it/1694mp2
@r_bash
I'm practicing my bash noscripting and want to request the user's sudo password using
dialog. Is it unsafe to request the password this way? And if so, how is it unsafe?As I'm new at this I would also appreciate any other suggestions/tips/comments!
Github link to current noscript here
​
I realize that sudo already has its own way of requesting the password, this is just for looks and practice. You could also just run the whole noscript as sudo but that's not the point of this exercise for me.
https://redd.it/1694mp2
@r_bash
GitHub
sudo-from-dialog/dialog-password at 7c436a652d7b96e8d26b54bb6ec44b2d7bcf818c · MajorMuff/sudo-from-dialog
Using the dialog command to get sudo access. Contribute to MajorMuff/sudo-from-dialog development by creating an account on GitHub.
Beginner How do I solve the "/bin/bash: ... No such file or directory"?
Hi!
I'm using Windows and I wrote the following Bash noscript:
```
\#!/bin/bash
cd C:\\Users\\username\\Downloads\\workspace\\project1
.\\venv\\Scripts\\activate
python python_noscript.py "Hello World!"
deactivate
node javanoscript_noscript.js "Hello World!"```
My goal is just to laud both the Python and JavaScript noscripts that just print Hello World!. I was having an issue with not finding the Python command hence the workaround to manually activate the virtual environment.
Now my issue is when I'm in the folder where the file is, my bash_noscript.sh is in "C:\\Users\\username\\Downloads\\workspace\\project1", and in the terminal I do ```bash bash_noscript.sh``` it gives me the following error: "/bin/bash: bash_noscript.sh: No such file or directory".
I tried giving it the absolute path of the bash noscript as well as "/mnt/C:/Users/username/Downloads/workspace/project1" but I get the same error.
I'd be really grateful if someone can help me figure this out. Thank you!
https://redd.it/169qju9
@r_bash
Hi!
I'm using Windows and I wrote the following Bash noscript:
```
\#!/bin/bash
cd C:\\Users\\username\\Downloads\\workspace\\project1
.\\venv\\Scripts\\activate
python python_noscript.py "Hello World!"
deactivate
node javanoscript_noscript.js "Hello World!"```
My goal is just to laud both the Python and JavaScript noscripts that just print Hello World!. I was having an issue with not finding the Python command hence the workaround to manually activate the virtual environment.
Now my issue is when I'm in the folder where the file is, my bash_noscript.sh is in "C:\\Users\\username\\Downloads\\workspace\\project1", and in the terminal I do ```bash bash_noscript.sh``` it gives me the following error: "/bin/bash: bash_noscript.sh: No such file or directory".
I tried giving it the absolute path of the bash noscript as well as "/mnt/C:/Users/username/Downloads/workspace/project1" but I get the same error.
I'd be really grateful if someone can help me figure this out. Thank you!
https://redd.it/169qju9
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
help why is diff taking so long? I just want to compare filenames between 2 folders to look for what's missing and print the differences. No recursion.
I know this shouldn't be that hard. I've definitely check contents of files against another but this is taking a long time. folder A has 100 items. Folder B hash 118. I just want those 18 not included. Like so:
diff /directoryA /directoryB
prints:
+ 18 files missing in /directoyB:
1. taco.txt
2. hello.txt
3. bread.txt
....
However everything I try is going incredible slow. I don't need to read the contents of the files. Just the filenames. I don't need to recursively check folders. Just a text match of the top level file/folder names within the given directory but it takes about 1 minute before it returns the next result.
I've tried these flags with diff: "-q" " "-brief" and "a" to treat as text but it's still to slow. "r" is recursive but it seems like it's doing that reguardless so how to I stop it from checking with folders?
Oh and I even tried this crazy thing:
diff <(find /Volumes/directory1/ -printf '%P\n') \
<(find /Volumes/directory2/ -printf '%P\n')
I could've done it manually by now but I must know how this is done!
https://redd.it/169yi6y
@r_bash
I know this shouldn't be that hard. I've definitely check contents of files against another but this is taking a long time. folder A has 100 items. Folder B hash 118. I just want those 18 not included. Like so:
diff /directoryA /directoryB
prints:
+ 18 files missing in /directoyB:
1. taco.txt
2. hello.txt
3. bread.txt
....
However everything I try is going incredible slow. I don't need to read the contents of the files. Just the filenames. I don't need to recursively check folders. Just a text match of the top level file/folder names within the given directory but it takes about 1 minute before it returns the next result.
I've tried these flags with diff: "-q" " "-brief" and "a" to treat as text but it's still to slow. "r" is recursive but it seems like it's doing that reguardless so how to I stop it from checking with folders?
Oh and I even tried this crazy thing:
diff <(find /Volumes/directory1/ -printf '%P\n') \
<(find /Volumes/directory2/ -printf '%P\n')
I could've done it manually by now but I must know how this is done!
https://redd.it/169yi6y
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Alacritty + bash + nixos Window noscript is not changing automatically like zsh
Is it normal or is there any workaround?
Dotfiles
https://redd.it/16a75o6
@r_bash
Is it normal or is there any workaround?
Dotfiles
https://redd.it/16a75o6
@r_bash
GitHub
GitHub - MobSenpai/dotfiles: ❄ Configuration For The Best Declarative Linux Distro, NixOS!
❄ Configuration For The Best Declarative Linux Distro, NixOS! - GitHub - MobSenpai/dotfiles: ❄ Configuration For The Best Declarative Linux Distro, NixOS!
Simple "fuzzy which" command line
I was working on dusting off my bash a little and thought a fun little project would be a which statement that would use fzf fuzzy search if couldn't quite remember the name of a command. Any improvements you guys can think of ? I mostly noscript in python so my noscripts tend to be fairly explicit and not try to put 10 steps in one line. Sorry for the "newb" quality in advance. This is a link to the noscript: https://pastebin.com/vq5FYJsv
Edit1: thanks to Hackenslacker I improved the exit with a "die" function
https://pastebin.com/G3vajxTx
https://redd.it/16abpxw
@r_bash
I was working on dusting off my bash a little and thought a fun little project would be a which statement that would use fzf fuzzy search if couldn't quite remember the name of a command. Any improvements you guys can think of ? I mostly noscript in python so my noscripts tend to be fairly explicit and not try to put 10 steps in one line. Sorry for the "newb" quality in advance. This is a link to the noscript: https://pastebin.com/vq5FYJsv
Edit1: thanks to Hackenslacker I improved the exit with a "die" function
https://pastebin.com/G3vajxTx
https://redd.it/16abpxw
@r_bash
Pastebin
#!/bin/bash#set -xset -e#bail if fzf not availablewhich -s fzf 2> /de - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Error when trying to setup crontab while launching an EC2 instance via user data
* I want to set up a bunch of cron jobs when I launch an EC2 instance
* I followed this guide [user data](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html)
* I wrote a bash noscript which I would like to execute as part of the user data at launch
Unfortunately the noscript below does not work for some reason (Amazon Linux 2 instance)
#!/usr/bin/env bash
set -e
set -E
set -o pipefail
set -u
set -x
IFS=$'\n\t'
crontab -r
crontab -l | { cat; echo "0 0,4,8,12,16,20 * * * bash /home/ec2-user/utils/src/rds/dump-rds-to-s3.sh > /tmp/dump-rds-to-s3.log 2>&1"; } | crontab -
crontab -l | { cat; echo "0 0,4,8,12,16,20 * * * bash /home/ec2-user/utils/src/elasticache/dump-elasticache-to-s3.sh > /tmp/dump-elasticache-to-s3.log 2>&1"; } | crontab -
It gives me an error saying
```
no crontab for root
```
When I run the noscript manually after launch, it gives me the error
```
No crontab for ec2-usser
```
Can someone kindly tell me how to add cron jobs automatically via bash noscript at launch time inside an EC2 instance via user data?
https://redd.it/16adynn
@r_bash
* I want to set up a bunch of cron jobs when I launch an EC2 instance
* I followed this guide [user data](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html)
* I wrote a bash noscript which I would like to execute as part of the user data at launch
Unfortunately the noscript below does not work for some reason (Amazon Linux 2 instance)
#!/usr/bin/env bash
set -e
set -E
set -o pipefail
set -u
set -x
IFS=$'\n\t'
crontab -r
crontab -l | { cat; echo "0 0,4,8,12,16,20 * * * bash /home/ec2-user/utils/src/rds/dump-rds-to-s3.sh > /tmp/dump-rds-to-s3.log 2>&1"; } | crontab -
crontab -l | { cat; echo "0 0,4,8,12,16,20 * * * bash /home/ec2-user/utils/src/elasticache/dump-elasticache-to-s3.sh > /tmp/dump-elasticache-to-s3.log 2>&1"; } | crontab -
It gives me an error saying
```
no crontab for root
```
When I run the noscript manually after launch, it gives me the error
```
No crontab for ec2-usser
```
Can someone kindly tell me how to add cron jobs automatically via bash noscript at launch time inside an EC2 instance via user data?
https://redd.it/16adynn
@r_bash
Amazon
Run commands when you launch an EC2 instance with user data input - Amazon Elastic Compute Cloud
You can run commands to perform configuration tasks when you launch an instance by passing in a user data noscript as input.
How to read value of variable in this case?
Hello folks.
I have this bash noscript (im a beginner) where i have 3 directorys: A B and C.
These directorys have values, after how many days the files inside get deleted.
A = 1
B = 3
C = 2
Sources = $(find /Test/Source/* -maxdepth 0 -type d)
for o in $Sources; do
SD = $(basename -a $o)
SDC = `echo $SO | cut -d" " -f1`
echo $SDC
Done
This gives me the folders A B and C.
Now i want to create syntax for reading the corresponding timevalues. I dont want to use if questions and if possible no Array.
I thought of something like this :
echo $$SDC
This reads the Folder "A" but puts $ infront. So it makes $A which in return prints 1. Sadly it doesnt work exactly like that. But maybe someone has a idea on how to write this command.
Thanks in advance
https://redd.it/16an65u
@r_bash
Hello folks.
I have this bash noscript (im a beginner) where i have 3 directorys: A B and C.
These directorys have values, after how many days the files inside get deleted.
A = 1
B = 3
C = 2
Sources = $(find /Test/Source/* -maxdepth 0 -type d)
for o in $Sources; do
SD = $(basename -a $o)
SDC = `echo $SO | cut -d" " -f1`
echo $SDC
Done
This gives me the folders A B and C.
Now i want to create syntax for reading the corresponding timevalues. I dont want to use if questions and if possible no Array.
I thought of something like this :
echo $$SDC
This reads the Folder "A" but puts $ infront. So it makes $A which in return prints 1. Sadly it doesnt work exactly like that. But maybe someone has a idea on how to write this command.
Thanks in advance
https://redd.it/16an65u
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
WTF happened to "history -w/-r".
I am missing the ability to write the shell buffer to history and read the history from the history file...
https://redd.it/16b2d50
@r_bash
I am missing the ability to write the shell buffer to history and read the history from the history file...
https://redd.it/16b2d50
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Default behavior for no explicit options?
If we do
Do you know any other commands that take in a default option?
https://redd.it/16b5nzn
@r_bash
If we do
ls | pr -5 (equivalent to ls | pr --column 5), how does the terminal know the -5 splits the columns into columns of 5. I've read through man pr and info pr but there is no information given on the default behavior of not having an explicit option. Do you know any other commands that take in a default option?
https://redd.it/16b5nzn
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Inserting a picture into a PDF heavily increases its size. Why?
This is a part of my noscript, that works with 8 pictures. I isolated this part to test it and check how can I prevent it to create heavy PDFs.
Objective: a noscript that creates an A4 blank PDF, and insert a picture without modifying the picture or its dimensions or resolution.
The picture sizes 170 KB. The blank A4 PDF sizes 136 KB. Both should create a ~306 KB. Instead, it creates a 2.9 MB PDF. It puts it in the right place and keeps the original resolution of the picture, but somehow it bloats it.
What am I missing?
#!/bin/bash
#### CONSTANT VALUES
imgpath=pic1.png # 170 KB
dpi=300
outputpage=testing.pdf
# Image dimensions in pixels
widthpixels=1181
heightpixels=787
# Dimensions of A4 paper in pixels
a4widthpixels=2479 # 21 cm
a4heightpixels=3508 # 29.7 cm
#### BLANK A4 PDF CREATION
convert -size ${a4widthpixels}x${a4heightpixels} xc:white -density $dpi $outputpage
echo "the PDF size is: "$(du -h $outputpage) # 163 KB
#### FUNCTION: integer from a float (there's no half pixel)
int() { echo $(env printf %.0f $(echo "scale=0;$1" | bc)); }
#### IMAGE PLACEMENT VARIABLES
# Margins and spacing
margintop=$(int $(echo "($a4heightpixels - $heightpixels) / 2" | bc -l))
marginbottom=$margintop
marginright=$(int $(echo "($a4widthpixels - $widthpixels) / 2" | bc -l))
marginleft=$marginright
# Specific image placement
xoffset=$(int $(echo "($a4widthpixels - $widthpixels) / 2" | bc -l))
yoffset=$(int $(echo "($a4heightpixels - $heightpixels) / 2" | bc -l))
echo "x,y="$xoffset","$yoffset
#### FINAL PDF CREATION
convert -density $dpi $outputpage $imgpath -geometry +$xoffset+$yoffset -composite $outputpage
echo "the PDF size is: "$(du -h $outputpage) # 2.9 MB
https://redd.it/16b6uh4
@r_bash
This is a part of my noscript, that works with 8 pictures. I isolated this part to test it and check how can I prevent it to create heavy PDFs.
Objective: a noscript that creates an A4 blank PDF, and insert a picture without modifying the picture or its dimensions or resolution.
The picture sizes 170 KB. The blank A4 PDF sizes 136 KB. Both should create a ~306 KB. Instead, it creates a 2.9 MB PDF. It puts it in the right place and keeps the original resolution of the picture, but somehow it bloats it.
What am I missing?
#!/bin/bash
#### CONSTANT VALUES
imgpath=pic1.png # 170 KB
dpi=300
outputpage=testing.pdf
# Image dimensions in pixels
widthpixels=1181
heightpixels=787
# Dimensions of A4 paper in pixels
a4widthpixels=2479 # 21 cm
a4heightpixels=3508 # 29.7 cm
#### BLANK A4 PDF CREATION
convert -size ${a4widthpixels}x${a4heightpixels} xc:white -density $dpi $outputpage
echo "the PDF size is: "$(du -h $outputpage) # 163 KB
#### FUNCTION: integer from a float (there's no half pixel)
int() { echo $(env printf %.0f $(echo "scale=0;$1" | bc)); }
#### IMAGE PLACEMENT VARIABLES
# Margins and spacing
margintop=$(int $(echo "($a4heightpixels - $heightpixels) / 2" | bc -l))
marginbottom=$margintop
marginright=$(int $(echo "($a4widthpixels - $widthpixels) / 2" | bc -l))
marginleft=$marginright
# Specific image placement
xoffset=$(int $(echo "($a4widthpixels - $widthpixels) / 2" | bc -l))
yoffset=$(int $(echo "($a4heightpixels - $heightpixels) / 2" | bc -l))
echo "x,y="$xoffset","$yoffset
#### FINAL PDF CREATION
convert -density $dpi $outputpage $imgpath -geometry +$xoffset+$yoffset -composite $outputpage
echo "the PDF size is: "$(du -h $outputpage) # 2.9 MB
https://redd.it/16b6uh4
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Once I reach 70% of the udemy courses, I start to get bored and impatient to finish the course. how do I deal with this issue?
noscript. Im currently learning nginx and bash shell noscripting. 80% through nginx course and 50% through bash course and I'm getting impatient. i want to finish nginx by tommorow. I've around 2 hrs of content remaining. And bash noscripting by next 2 weeks. How do I control myself? I am asking this because learning fast fast you learn less things. I want to be patient. how do I make myself patient. If I make my goal to finish nginx by next week and bash by this month, I'll really learn a lot of good stuffs. but how tf do I keep my patience? I'm in hurry to colelct the certificate and post in linkedin lol.
https://redd.it/16ci10g
@r_bash
noscript. Im currently learning nginx and bash shell noscripting. 80% through nginx course and 50% through bash course and I'm getting impatient. i want to finish nginx by tommorow. I've around 2 hrs of content remaining. And bash noscripting by next 2 weeks. How do I control myself? I am asking this because learning fast fast you learn less things. I want to be patient. how do I make myself patient. If I make my goal to finish nginx by next week and bash by this month, I'll really learn a lot of good stuffs. but how tf do I keep my patience? I'm in hurry to colelct the certificate and post in linkedin lol.
https://redd.it/16ci10g
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
What level does using mindepth or maxdepth for a find command start at?
I am writing a bash noscript and a little unsure about the min/max depth option for the find command.
I have this find command and want to add maxdepth and mindepth to it
find /local/applogs/archive/ -type d -mtime +366 -exec echo {} \;
And this is the full depth of the directory, what number would I use for the depth options?
/local/applogs/archive/host/comp/2021/01/
The point of the find will eventually be to find any empty directories that are over a year old and remove them using rmdir which should make sure they are empty. Except it should only remove old, empty year and month (2021 and 01) directories.
Would I start the depth count from / or from the directory I am beginning my search (archive)?
​
https://redd.it/16cgem5
@r_bash
I am writing a bash noscript and a little unsure about the min/max depth option for the find command.
I have this find command and want to add maxdepth and mindepth to it
find /local/applogs/archive/ -type d -mtime +366 -exec echo {} \;
And this is the full depth of the directory, what number would I use for the depth options?
/local/applogs/archive/host/comp/2021/01/
The point of the find will eventually be to find any empty directories that are over a year old and remove them using rmdir which should make sure they are empty. Except it should only remove old, empty year and month (2021 and 01) directories.
Would I start the depth count from / or from the directory I am beginning my search (archive)?
​
https://redd.it/16cgem5
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
A working alternative to someprogram & disown & exit
I have trawled around looking for a solution for what seems should be fairly trivial.
It's worth noting that I am using wayland (**insert rant about not being able to generalize over compositors, this is the one thing making me think of switching back to X).
I have tried all manner of things including fetching the id of the current window, launching the program, disowning, & then closing the window with the id, but after running disown the call to exit or whatever after is never ran leaving the term open.
Any suggestions at all?
Still a bit of a bash novice, any reading materials also appreciated. Thanks.
https://redd.it/16cm8d8
@r_bash
I have trawled around looking for a solution for what seems should be fairly trivial.
It's worth noting that I am using wayland (**insert rant about not being able to generalize over compositors, this is the one thing making me think of switching back to X).
I have tried all manner of things including fetching the id of the current window, launching the program, disowning, & then closing the window with the id, but after running disown the call to exit or whatever after is never ran leaving the term open.
Any suggestions at all?
Still a bit of a bash novice, any reading materials also appreciated. Thanks.
https://redd.it/16cm8d8
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
writing a single line of a process output to a file
Hello, i want to write a single line of a process to a file , basically i want a command to write a single line to a file when there is a new notification. i tried different things without success:
dbus-monitor "member='Notify',interface='org.freedesktop.Notifications'" | grep-e "member=Notify" | while read line;do
echo "new line" >> ca.txt
done
​
dbus-monitor "member='Notify',interface='org.freedesktop.Notifications'" | grep-e "member=Notify" | while read line;do
tee -a ca.txt
done
​
dbus-monitor "member='Notify',interface='org.freedesktop.Notifications'" | tee company.txt >(grep "member=Notify" >> ad.txt)
but it seems the grep output isn't redirected to tee or echo . when i add -m1 flag to grep it writes the single line to the file but after 3 times the command exits but i want it to keep running . does anyone knows what im doing wrong?
https://redd.it/16cpa3v
@r_bash
Hello, i want to write a single line of a process to a file , basically i want a command to write a single line to a file when there is a new notification. i tried different things without success:
dbus-monitor "member='Notify',interface='org.freedesktop.Notifications'" | grep-e "member=Notify" | while read line;do
echo "new line" >> ca.txt
done
​
dbus-monitor "member='Notify',interface='org.freedesktop.Notifications'" | grep-e "member=Notify" | while read line;do
tee -a ca.txt
done
​
dbus-monitor "member='Notify',interface='org.freedesktop.Notifications'" | tee company.txt >(grep "member=Notify" >> ad.txt)
but it seems the grep output isn't redirected to tee or echo . when i add -m1 flag to grep it writes the single line to the file but after 3 times the command exits but i want it to keep running . does anyone knows what im doing wrong?
https://redd.it/16cpa3v
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community