What color scheme do you use for LS_COLORS?
Are there any specific elements of color scheming that you find particularly useful?
https://redd.it/yy7oyb
@r_bash
Are there any specific elements of color scheming that you find particularly useful?
https://redd.it/yy7oyb
@r_bash
reddit
What color scheme do you use for LS_COLORS?
Are there any specific elements of color scheming that you find particularly useful?
Noob Attempts to write a bash noscript
So, I have been attempting to write a bash noscript, but I don't entirely know what I am doing. I have tried to test out what others have suggested I use/change, but everything in my vm seems to not to see them. I don't know if it changes anything, but the bash noscript is running in vi on a ubuntu console. Anyway, to the actual noscript.
"#"!/bin/bash -x
echo 'Enter the Directory: '
read dd
#This section serves to test if the input is a directory. Following the test, it will resound with a yes or a no.
if -d $dd
then
#If yes, then it will then check if it has a file with the above name. If it does not, it will ask if the person wants it to be created.
echo '$dd is valid directory and it. exists. '
if test -f '$dd'; then
echo '$dd file exists.'
else
read YN
echo '$dd file does not exist. Do you want to create it Y/N? $YN'
#This line below confuses me, but that is because I don't know what is going on.
if [ "$YN" =~ ^(no|No|NO|n|N)$ ] ; then
echo 'File will not be created.'
else
echo 'File will be created.'
touch $dd
fi
fi
else
#It is then suppose to do the same as above, but with a directory instead.
echo '$directory does not exist. Do you want to create it Y/N? $YN'
if [ "$YN" =~ ^(no|No|NO|n|N)$ ] ; then
echo 'Directory will not be created.'
else
echo 'Directory will be created.'
mkdir $dd
fi
fi
The output I am currently getting:
Enter the Directory:
s
$directory does not exist. Do you want to create it Y/N? $YN
Directory will be created.
I don't know what is going wrong. I have tried running it in shellcheck, but the most insight I have gained is "read without -r will mangle backslashes" & "Expressions don't expand in single quotes, use double quotes for that." What am I doing wrong.
https://redd.it/yyeyhc
@r_bash
So, I have been attempting to write a bash noscript, but I don't entirely know what I am doing. I have tried to test out what others have suggested I use/change, but everything in my vm seems to not to see them. I don't know if it changes anything, but the bash noscript is running in vi on a ubuntu console. Anyway, to the actual noscript.
"#"!/bin/bash -x
echo 'Enter the Directory: '
read dd
#This section serves to test if the input is a directory. Following the test, it will resound with a yes or a no.
if -d $dd
then
#If yes, then it will then check if it has a file with the above name. If it does not, it will ask if the person wants it to be created.
echo '$dd is valid directory and it. exists. '
if test -f '$dd'; then
echo '$dd file exists.'
else
read YN
echo '$dd file does not exist. Do you want to create it Y/N? $YN'
#This line below confuses me, but that is because I don't know what is going on.
if [ "$YN" =~ ^(no|No|NO|n|N)$ ] ; then
echo 'File will not be created.'
else
echo 'File will be created.'
touch $dd
fi
fi
else
#It is then suppose to do the same as above, but with a directory instead.
echo '$directory does not exist. Do you want to create it Y/N? $YN'
if [ "$YN" =~ ^(no|No|NO|n|N)$ ] ; then
echo 'Directory will not be created.'
else
echo 'Directory will be created.'
mkdir $dd
fi
fi
The output I am currently getting:
Enter the Directory:
s
$directory does not exist. Do you want to create it Y/N? $YN
Directory will be created.
I don't know what is going wrong. I have tried running it in shellcheck, but the most insight I have gained is "read without -r will mangle backslashes" & "Expressions don't expand in single quotes, use double quotes for that." What am I doing wrong.
https://redd.it/yyeyhc
@r_bash
reddit
Noob Attempts to write a bash noscript
So, I have been attempting to write a bash noscript, but I don't entirely know what I am doing. I have tried to test out what others have suggested...
Get the previous command output buffer
I'm working on a helper noscript that needs to run after every command to analyze its exit status and output logs.
I understand that stdout/stderr buffers are not stored on pseudo terminals. I therefore looked for a way to "save" this output to a temporary file before every command then read it after.
Here's what I added to my
Except when i load a new terminal and enter a command (say
Is what I'm trying to achieve possible? And if so what am I missing here?
Cheers!
https://redd.it/yyjhxo
@r_bash
I'm working on a helper noscript that needs to run after every command to analyze its exit status and output logs.
I understand that stdout/stderr buffers are not stored on pseudo terminals. I therefore looked for a way to "save" this output to a temporary file before every command then read it after.
Here's what I added to my
.bashrc:LAST_OUTPUT_LOG_FILE="~/zero.log"
exec 3>&1 1> >(tee $LAST_OUTPUT_LOG_FILE >&3)
# based on https://superuser.com/a/1111512/1748711
echo "Using $LAST_OUTPUT_LOG_FILE"
precmd () {
LAST_STATUS=$?
LAST_COMMAND=$(fc -ln -1)
echo "Last command: $LAST_COMMAND exited with status $LAST_STATUS"
echo "--------------- LAST COMMAND LOG $LAST_OUTPUT_LOG_FILE ---------------"
cat $LAST_OUTPUT_LOG_FILE
echo "--------------- LAST COMMAND LOG $LAST_OUTPUT_LOG_FILE ---------------"
# run my noscript here with the last command, its status and its output
# reset the log file
echo "" > $LAST_OUTPUT_LOG_FILE
}
export PROMPT_COMMAND=precmd
Except when i load a new terminal and enter a command (say
ls) I get the following error:precmd:echo:3: write error: broken pipe
precmd:3: write error: broken pipe
precmd:echo:4: write error: broken pipe
precmd:4: write error: broken pipe
cat: ~/zero.log: No such file or directory
precmd:echo:6: write error: broken pipe
precmd:6: write error: broken pipe
precmd:10: no such file or directory: ~/zero.log
Is what I'm trying to achieve possible? And if so what am I missing here?
Cheers!
https://redd.it/yyjhxo
@r_bash
reddit
Get the previous command output buffer
I'm working on a helper noscript that needs to run after every command to analyze its exit status and output logs. I understand that stdout/stderr...
If no STDIN read from File
I want a noscript which either writes STDIN to a file or if no STDIN present it reads from that file.
How could I do this? If I use cat to read STDIN, but there is no input it hangs.
Thanks
https://redd.it/yysmhu
@r_bash
I want a noscript which either writes STDIN to a file or if no STDIN present it reads from that file.
How could I do this? If I use cat to read STDIN, but there is no input it hangs.
Thanks
https://redd.it/yysmhu
@r_bash
reddit
If no STDIN read from File
I want a noscript which either writes STDIN to a file or if no STDIN present it reads from that file. How could I do this? If I use cat to read...
How to do a one liner for a CLI login which asks for a access token after login command?
I'm using beta version of a CLI as a tester which keeps asking for logging in with a access token each week when I use it. In bash terminal after I run
Thanks for helping
https://redd.it/yzb4kq
@r_bash
I'm using beta version of a CLI as a tester which keeps asking for logging in with a access token each week when I use it. In bash terminal after I run
noah login it prompts like this Enter access token > . How can I do this in a one liner like noah login > access_token? Thanks for helping
https://redd.it/yzb4kq
@r_bash
reddit
How to do a one liner for a CLI login which asks for a access...
I'm using beta version of a CLI as a tester which keeps asking for logging in with a access token each week when I use it. In bash terminal after...
questions about echo appending
Hello, so my problem with "echo >>" that I do not understand:
I have two files input.txt and output.txt when I loop through the lines of the first file and use "echo >>" to move them to the outputfile I have a blank first line. I understand that echo appends but then I have to question how to get rid of that? Is there no other way than deleting the first line (which seems unnecssary)?
Also if someone could explain why that behaviour is necessary instead of >> just appending beginning in the first line, that would be interesting as well.
Edit: So what my problem was, is that I did not realize that echo with no arguments does echo a blank line, so when I used it to delete the contents of a file I unwillingly inserted a blank line into it. Seems like just "> filename" is a better way to delete the contents of a file
https://redd.it/yzd9dn
@r_bash
Hello, so my problem with "echo >>" that I do not understand:
I have two files input.txt and output.txt when I loop through the lines of the first file and use "echo >>" to move them to the outputfile I have a blank first line. I understand that echo appends but then I have to question how to get rid of that? Is there no other way than deleting the first line (which seems unnecssary)?
Also if someone could explain why that behaviour is necessary instead of >> just appending beginning in the first line, that would be interesting as well.
Edit: So what my problem was, is that I did not realize that echo with no arguments does echo a blank line, so when I used it to delete the contents of a file I unwillingly inserted a blank line into it. Seems like just "> filename" is a better way to delete the contents of a file
https://redd.it/yzd9dn
@r_bash
reddit
questions about echo appending
Hello, so my problem with "echo >>" that I do not understand: I have two files input.txt and output.txt when I loop through the lines of the...
If eval find...
I have archives of archives, at least. I would like a noscript to recursively verify all archives and sub-archives for integrity. What I have works, but I know it's dumb.
Rather than making recursion with a function that calls itself (too confusing, IDK), I've decided to just manually run
declare home="${PWD}"
find . -iname '.zip' -exec sh -c '! [[ -f "${0}.val" ]] && unzip -o -d "${0%.}" "$0" && echo "$0">>$0.val' '{}' \;
find . -iname '.zip' -exec sh -c '! [[ -f "${0}.val" ]] && echo "[ERR] $0"' '{}' \;
#----------
if (
find . -iname '.zip' -exec sh -c '! [ -f "${0}.val" ] && echo "ERR $0">>"${home}log.txt"' '{}' \;
); then
echo " GOOD "
else
echo " FAIL "
fi
So, it finds zip files, and if it doesn't find "zipfile.zip.val", it extracts the contents and creates a dummy file (.val) to denote successful extraction. Then, this second part searches to make sure every .zip has an accompanying dummy file (.val).
The bottom section also just checks for the .val dummy files but instead of echo output, it just logs them and echos whether there were archives with missing .val files or not.
So, it just needs to recursively examine an archive of archives to ensure zip integrity. This is as close as I've gotten. Thanks.
OOPS: I've read that eval may be suggested over my "if (find)" sub shell method. If nothing else, maybe we can answer that!
https://redd.it/yzeqx4
@r_bash
I have archives of archives, at least. I would like a noscript to recursively verify all archives and sub-archives for integrity. What I have works, but I know it's dumb.
Rather than making recursion with a function that calls itself (too confusing, IDK), I've decided to just manually run
find a few times. Ugh. It's still far from what I want.declare home="${PWD}"
find . -iname '.zip' -exec sh -c '! [[ -f "${0}.val" ]] && unzip -o -d "${0%.}" "$0" && echo "$0">>$0.val' '{}' \;
find . -iname '.zip' -exec sh -c '! [[ -f "${0}.val" ]] && echo "[ERR] $0"' '{}' \;
#----------
if (
find . -iname '.zip' -exec sh -c '! [ -f "${0}.val" ] && echo "ERR $0">>"${home}log.txt"' '{}' \;
); then
echo " GOOD "
else
echo " FAIL "
fi
So, it finds zip files, and if it doesn't find "zipfile.zip.val", it extracts the contents and creates a dummy file (.val) to denote successful extraction. Then, this second part searches to make sure every .zip has an accompanying dummy file (.val).
The bottom section also just checks for the .val dummy files but instead of echo output, it just logs them and echos whether there were archives with missing .val files or not.
So, it just needs to recursively examine an archive of archives to ensure zip integrity. This is as close as I've gotten. Thanks.
OOPS: I've read that eval may be suggested over my "if (find)" sub shell method. If nothing else, maybe we can answer that!
https://redd.it/yzeqx4
@r_bash
reddit
If eval find...
I have archives of archives, at least. I would like a noscript to recursively verify all archives and sub-archives for integrity. What I have works,...
longest||coolest Linux pipes you have written
Hello there,it's Saturday and I'm trying to cill reading about awsome pipes. Have you any cool pipe to show off?
https://redd.it/yzfh5k
@r_bash
Hello there,it's Saturday and I'm trying to cill reading about awsome pipes. Have you any cool pipe to show off?
https://redd.it/yzfh5k
@r_bash
reddit
longest||coolest Linux pipes you have written
Hello there,it's Saturday and I'm trying to cill reading about awsome pipes. Have you any cool pipe to show off?
Yet another PS1
pardon my MSYS2 setup, I don't get to decide which system I'm working on
After a metric ton of refinements, I proudly present my personal PS1 with the following features:
Colors (duh!)
Git branch + additions/deletions (Github style)
List of managed jobs
Duration and status of the last command
Left-right design
Written 100% in bash and blazing fast (okay, I may have used sed once...)
Portable (works on Windows)
Easy to configure
Here it is : https://github.com/bdelespierre/dotfiles/blob/master/bash/.bash\_ps1
I am not a bash expert, and I would love to hear your comments on that work.
Thank you for your time and have a great day!
https://redd.it/yzgxax
@r_bash
pardon my MSYS2 setup, I don't get to decide which system I'm working on
After a metric ton of refinements, I proudly present my personal PS1 with the following features:
Colors (duh!)
Git branch + additions/deletions (Github style)
List of managed jobs
Duration and status of the last command
Left-right design
Written 100% in bash and blazing fast (okay, I may have used sed once...)
Portable (works on Windows)
Easy to configure
Here it is : https://github.com/bdelespierre/dotfiles/blob/master/bash/.bash\_ps1
I am not a bash expert, and I would love to hear your comments on that work.
Thank you for your time and have a great day!
https://redd.it/yzgxax
@r_bash
I don't understand this printf behavior
Hello everybody!
I'm new-ish to bash and found this while I was tinkering with `printf`. Let's say that I have the following noscript:
#!/usr/bin/env bash
printf -v test '%-14.*s' 14 '123456789ABCDFGH'
printf "%b\n" \
" ╭─demo─────────╮╮" \
" │ $test " \
" ╰──────────────╯"
the output comes out with 2 extra spaces added
​
[How it comes out with just the text \\"123456789ABCDFGH\\" as the value](https://preview.redd.it/jcnkbyanv01a1.png?width=182&format=png&auto=webp&s=e3fe7ee5985e5db73fa26b0faa36ce1b15da9627)
​
but when I set the `test` variable to `printf -v test '%-14.*s' 14 '│123456789ABCDFGH'` it comes out shifted
​
[How it comes out with \\"│123456789ABCDFGH\\" as the value](https://preview.redd.it/b6xsteddw01a1.png?width=155&format=png&auto=webp&s=8e2cdd2479fceaf8b0096d2da1dced469f1ae681)
​
I've also noticed this happening with nerd-font emojis (which is where I first noticed this happening), so I wonder, is there a reason why this occurs when I add the pipe "│" symbol? And if possible, can I make it always produce the second picture looking result (the shifted one), regardless of having or not the pipe?
https://redd.it/yzugcz
@r_bash
Hello everybody!
I'm new-ish to bash and found this while I was tinkering with `printf`. Let's say that I have the following noscript:
#!/usr/bin/env bash
printf -v test '%-14.*s' 14 '123456789ABCDFGH'
printf "%b\n" \
" ╭─demo─────────╮╮" \
" │ $test " \
" ╰──────────────╯"
the output comes out with 2 extra spaces added
​
[How it comes out with just the text \\"123456789ABCDFGH\\" as the value](https://preview.redd.it/jcnkbyanv01a1.png?width=182&format=png&auto=webp&s=e3fe7ee5985e5db73fa26b0faa36ce1b15da9627)
​
but when I set the `test` variable to `printf -v test '%-14.*s' 14 '│123456789ABCDFGH'` it comes out shifted
​
[How it comes out with \\"│123456789ABCDFGH\\" as the value](https://preview.redd.it/b6xsteddw01a1.png?width=155&format=png&auto=webp&s=8e2cdd2479fceaf8b0096d2da1dced469f1ae681)
​
I've also noticed this happening with nerd-font emojis (which is where I first noticed this happening), so I wonder, is there a reason why this occurs when I add the pipe "│" symbol? And if possible, can I make it always produce the second picture looking result (the shifted one), regardless of having or not the pipe?
https://redd.it/yzugcz
@r_bash
(F18) cis student need help writing an awkward command file for price calculation, professor won't help.
So I am given documents on the file I start with:
Sales for week ending November 20, 2022
"Item Price Mon Tue Wed Thu Fri Sat Sun
----------------‐----------------------------------------------------------------------------------------------------------------------
Cones 3.50 23 12 11 37 55 69 70
Ice Cream Floats 3.50 5 4 13 9 42 16 35
Sodas 2.50 10 20 13 16 22 39 25
Dipped Cones 4.50 13 14 0 22 25 35 55
Banana Splits 7.50 7 17 0 12 12 20 30
Milkshakes 5.00 16 14 15 30 37 38 41
Sundaes 6.00 11 9 12 21 20 43 34"
What I am supposed to do is write an awk command file using vim that when the command line "awk -f salesSummary.awk ProductSales.txt" is entered will output exactly this:
"Item Mon Tue Wed Thu Fri Sat Sun Total
‐----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Cones $ 80.50 $ 42.00 $ 38.50 $129.50 $192.50 $241.50 $245.00 $ 969.50
Ice Cream Floats $ 17.50 $ 14.00 $ 45.50 $ 31.50 $147.00 $ 56.00 $122.50 $ 434.00
Sodas $ 25.00 $ 50.00 $ 32.50 $ 40.00 $ 55.00 $ 97.50 $ 62.50 $ 362.50
Dipped Cones $ 58.50 $ 63.00 $ 0.00 $ 99.00 $112.50 $157.50 $247.50 $ 738.00
Banana Splits $ 52.50 $127.50 $ 0.00 $ 90.00 $ 90.00 $150.00 $225.00 $ 735.00
Milkshakes $ 80.00 $ 70.00 $ 75.00 $150.00 $185.00 $190.00 $205.00 $ 955.00
Sundaes $ 66.00 $ 54.00 $ 72.00 $126.00 $120.00 $258.00 $204.00 $ 900.00
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sales for week ending November 20, 2022
Total Sales: $5094.00
Top Seller $ 969.50 -- Cones"
What I know so far is that I structure an awk file with this syntax:
BEGIN {
-
-
-
-
}{
-
-
-
-
}
END{
-
-
}
Professor says that code is quite similar to Java but I am still lost :(
How would I go about writing this?
Ps sorry I've never used reddit before apologies for bad format.
https://redd.it/yztzir
@r_bash
So I am given documents on the file I start with:
Sales for week ending November 20, 2022
"Item Price Mon Tue Wed Thu Fri Sat Sun
----------------‐----------------------------------------------------------------------------------------------------------------------
Cones 3.50 23 12 11 37 55 69 70
Ice Cream Floats 3.50 5 4 13 9 42 16 35
Sodas 2.50 10 20 13 16 22 39 25
Dipped Cones 4.50 13 14 0 22 25 35 55
Banana Splits 7.50 7 17 0 12 12 20 30
Milkshakes 5.00 16 14 15 30 37 38 41
Sundaes 6.00 11 9 12 21 20 43 34"
What I am supposed to do is write an awk command file using vim that when the command line "awk -f salesSummary.awk ProductSales.txt" is entered will output exactly this:
"Item Mon Tue Wed Thu Fri Sat Sun Total
‐----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Cones $ 80.50 $ 42.00 $ 38.50 $129.50 $192.50 $241.50 $245.00 $ 969.50
Ice Cream Floats $ 17.50 $ 14.00 $ 45.50 $ 31.50 $147.00 $ 56.00 $122.50 $ 434.00
Sodas $ 25.00 $ 50.00 $ 32.50 $ 40.00 $ 55.00 $ 97.50 $ 62.50 $ 362.50
Dipped Cones $ 58.50 $ 63.00 $ 0.00 $ 99.00 $112.50 $157.50 $247.50 $ 738.00
Banana Splits $ 52.50 $127.50 $ 0.00 $ 90.00 $ 90.00 $150.00 $225.00 $ 735.00
Milkshakes $ 80.00 $ 70.00 $ 75.00 $150.00 $185.00 $190.00 $205.00 $ 955.00
Sundaes $ 66.00 $ 54.00 $ 72.00 $126.00 $120.00 $258.00 $204.00 $ 900.00
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sales for week ending November 20, 2022
Total Sales: $5094.00
Top Seller $ 969.50 -- Cones"
What I know so far is that I structure an awk file with this syntax:
BEGIN {
-
-
-
-
}{
-
-
-
-
}
END{
-
-
}
Professor says that code is quite similar to Java but I am still lost :(
How would I go about writing this?
Ps sorry I've never used reddit before apologies for bad format.
https://redd.it/yztzir
@r_bash
reddit
(F18) cis student need help writing an awkward command file for...
So I am given documents on the file I start with: Sales for week ending November 20, 2022 "Item Price Mon Tue Wed Thu ...
Trap exit function
I have 2 questions regarding trapping exit.
1. Should the trap command come after the trap function? I assume it should, though it works with it before the trap function.
2. Why doesn't trapping exit cause a loop when the trap function exits?
Sample section of the code I've been using without any issue:
#!/usr/bin/env bash
# Trap noscript terminating errors and exit so we can clean up
trap cleanup 1 2 3 6 15 EXIT
# Tmp logs clean up function
cleanup() {
arg1=$?
# Move tmperrorlog to error log if tmperrorlog is not empty
if [ -s $Tmp_Err_Log_File ] && [ -d $Backup_Directory ]; then
mv "${TmpErrLogFile}" "${ErrLogFile}"
if [[ $? -gt "0" ]]; then
echo "WARN: Failed moving ${TmpErrLogFile} to ${ErrLogFile}" |& tee -a "${ErrLogFile}"
fi
fi
# Delete our tmp directory
if [ -d $Tmp_Dir ]; then
rm -rf "${TmpDir}"
if [[ $? -gt "0" ]]; then
echo "WARN: Failed deleting ${TmpDir}" |& tee -a "${ErrLogFile}"
fi
fi
exit "${arg1}"
}
# other code here
exit
https://redd.it/z026d9
@r_bash
I have 2 questions regarding trapping exit.
1. Should the trap command come after the trap function? I assume it should, though it works with it before the trap function.
2. Why doesn't trapping exit cause a loop when the trap function exits?
Sample section of the code I've been using without any issue:
#!/usr/bin/env bash
# Trap noscript terminating errors and exit so we can clean up
trap cleanup 1 2 3 6 15 EXIT
# Tmp logs clean up function
cleanup() {
arg1=$?
# Move tmperrorlog to error log if tmperrorlog is not empty
if [ -s $Tmp_Err_Log_File ] && [ -d $Backup_Directory ]; then
mv "${TmpErrLogFile}" "${ErrLogFile}"
if [[ $? -gt "0" ]]; then
echo "WARN: Failed moving ${TmpErrLogFile} to ${ErrLogFile}" |& tee -a "${ErrLogFile}"
fi
fi
# Delete our tmp directory
if [ -d $Tmp_Dir ]; then
rm -rf "${TmpDir}"
if [[ $? -gt "0" ]]; then
echo "WARN: Failed deleting ${TmpDir}" |& tee -a "${ErrLogFile}"
fi
fi
exit "${arg1}"
}
# other code here
exit
https://redd.it/z026d9
@r_bash
reddit
Trap exit function
I have 2 questions regarding trapping exit. 1. Should the trap command come after the trap function? I assume it should, though it works with it...
"echo hello > /dev/stdout | echo world" does't make sense
Hello everyone I'm trying to understand this command behaviour, I'm remaking a shell for a school project and bash --posix behaviour looks weird to me.
Why does this command only print "world" ?
My understanding is that bash create the pipe, close it and redirect the first command STDOUT to /dev/stdout so why won't it print "hello" on the terminal ?
https://redd.it/z02289
@r_bash
Hello everyone I'm trying to understand this command behaviour, I'm remaking a shell for a school project and bash --posix behaviour looks weird to me.
Why does this command only print "world" ?
My understanding is that bash create the pipe, close it and redirect the first command STDOUT to /dev/stdout so why won't it print "hello" on the terminal ?
https://redd.it/z02289
@r_bash
reddit
"echo hello > /dev/stdout | echo world" does't make sense
Hello everyone I'm trying to understand this command behaviour, I'm remaking a shell for a school project and bash --posix behaviour looks weird...
Grep a*b
Hello
How can I use grep to show only line that have a*b and a*c and a*d ( the à is repeated in all strings, the * can be anything and the C is the value that I'mlooking for).
Thanks
https://redd.it/z03wyn
@r_bash
Hello
How can I use grep to show only line that have a*b and a*c and a*d ( the à is repeated in all strings, the * can be anything and the C is the value that I'mlooking for).
Thanks
https://redd.it/z03wyn
@r_bash
reddit
Grep a*b
Hello How can I use grep to show only line that have a*b and a*c and a*d ( the à is repeated in all strings, the * can be anything and the C is...
extract key and value from log
I try extract key and value from but I can’t do it:
2022-11-20 11:52:20 - Processing ProtocolSpec: {'status': 'SENDERR:FileSender.sendFile:ProtocolException("error(111, \\'Connection refused\\')[Errno 111\] Connection refused",)error(111, \\'Connection refused\\')[Errno 111\] Connection refused', 'datamode': 'att', 'contenttype': 'html', 'warnings': 'Malformed cco email address: . Malformed cco email address: . ', 'datatype': 'bin', 'backup': '1', 'from_addr': 'mail@mail', 'to_addr': [u'user@mail'\], 'filename': 'XX.00XX.XXX.X.000000.CMAS.zip', 'actions': [u'zip'\], 'ser_key': 'protocol', 'content': 'File Attached.<BR><BR>Report', 'cco_addr': [u''\], 'fid': '20149431.00', 'alert_done': 0, 'type': 'mailbody', 'onemptydata': 'process', 'subject': 'TID FILE'}
i need extract this 'filename': 'XX.00XX.XXX.X.000000.CMAS.zip'
any helps?
regards,
https://redd.it/z062mx
@r_bash
I try extract key and value from but I can’t do it:
2022-11-20 11:52:20 - Processing ProtocolSpec: {'status': 'SENDERR:FileSender.sendFile:ProtocolException("error(111, \\'Connection refused\\')[Errno 111\] Connection refused",)error(111, \\'Connection refused\\')[Errno 111\] Connection refused', 'datamode': 'att', 'contenttype': 'html', 'warnings': 'Malformed cco email address: . Malformed cco email address: . ', 'datatype': 'bin', 'backup': '1', 'from_addr': 'mail@mail', 'to_addr': [u'user@mail'\], 'filename': 'XX.00XX.XXX.X.000000.CMAS.zip', 'actions': [u'zip'\], 'ser_key': 'protocol', 'content': 'File Attached.<BR><BR>Report', 'cco_addr': [u''\], 'fid': '20149431.00', 'alert_done': 0, 'type': 'mailbody', 'onemptydata': 'process', 'subject': 'TID FILE'}
i need extract this 'filename': 'XX.00XX.XXX.X.000000.CMAS.zip'
any helps?
regards,
https://redd.it/z062mx
@r_bash
BashLib a helpful source file for any noscript
This is something I made awhile back. Its extremely useful for making games, if youre into that, but it is good for just about anything really. Im open to suggestions.
https://github.com/DethByte64/BashLib
https://redd.it/z09oiu
@r_bash
This is something I made awhile back. Its extremely useful for making games, if youre into that, but it is good for just about anything really. Im open to suggestions.
https://github.com/DethByte64/BashLib
https://redd.it/z09oiu
@r_bash
GitHub
GitHub - DethByte64/BashLib: A Bash Source file that contains many useful functions.
A Bash Source file that contains many useful functions. - GitHub - DethByte64/BashLib: A Bash Source file that contains many useful functions.
Displaying datas in an array
Hello,
I'm trying to draw an array for displaying datas. I succeeded for the first row with as many columns I want, but I have a trouble to draw the others rows. I think there is an easy way to do it. Could you help me ?
drawarray()
`{`
`border=("╔" "═" "╗" "║" "╚" "╝" "╠" "╩" "╦" "╣" "╬")`
`posx=$1 ; posy=$2 ; borderbg=$3 ; borderclr=$4 ; nbcols=$5 ; nbrows=$6`
`shift 6`
`columns=1 ; rows=1 ; height=1 ; arrayrows=1
`leftmid=${border0} ; midmid=${border[8]} ; rightmid=${border2}
`for loopcolumns in `seq 1 $nbcols\``
`do`
`widthcell$loop_columns=$1 ; heightcell=$2`
`for loop in \`seq 1 ${widthcell$loop_columns}` ; do printf "%s" $hor ; done
if [[ $cols -lt $nbcolumns ]] || [ $cols -gt 1 ] && [ $cols -lt $nb_columns ] || [ $cols -eq $nb_columns ] ; then
printf "%s\n" $ver
fi
done
((height++))
if [ $loop_columns -eq $nb_cols ] ; then posx=$posx2 ; fi
`do`
for loop in \seq 1 ${widthcell$loop_columns}
if [ $cols -lt $nb_cols ] ; then
printf "%s" $middown
elif [[ $cols -gt 1 ]] && [[ $cols -lt $nbcols ]] ; then
printf "%s" $middown
elif [[ $cols -eq $nbcols ]] ; then
printf "%s\n" $rightdown
fi
((cols++))
`done`
`echo`
`echo`
`tput sgr 0`
`}`
and here the command to call it :
drawarray 10 12 0 7 4 3 20 15 10 5 3 20 15 10 5 3
​
and the result :
╔════════════════════╦═══════════════╦══════════╦═════╗
║ ║ ║ ║. ║
║ ║ ║ ║. ║
║ ║ ║ ║. ║.
╠════════════════════╬═══════════════╬══════════╬═════╣
​
https://redd.it/z0daiu
@r_bash
Hello,
I'm trying to draw an array for displaying datas. I succeeded for the first row with as many columns I want, but I have a trouble to draw the others rows. I think there is an easy way to do it. Could you help me ?
drawarray()
`{`
`border=("╔" "═" "╗" "║" "╚" "╝" "╠" "╩" "╦" "╣" "╬")`
`posx=$1 ; posy=$2 ; borderbg=$3 ; borderclr=$4 ; nbcols=$5 ; nbrows=$6`
`shift 6`
`columns=1 ; rows=1 ; height=1 ; arrayrows=1
tput setab $borderbg ; tput setaf $borderclr ; tput cup $posy $posx
leftup=${border[0]} ; midup=${border8} ; rightup=${border[2]} ; hor=${border[1]} ; ver=${border[3]}``leftmid=${border0} ; midmid=${border[8]} ; rightmid=${border2}
printf "%s" $leftup``for loopcolumns in `seq 1 $nbcols\``
`do`
`widthcell$loop_columns=$1 ; heightcell=$2`
`for loop in \`seq 1 ${widthcell$loop_columns}` ; do printf "%s" $hor ; done
if [ $columns -lt $nb_cols ] ; then
printf "%s" $mid_up
elif [ $columns -gt 1 ] && [ $columns -lt $nb_cols ] ; then
printf "%s" $mid_up
elif [ $columns -eq $nb_cols ] ; then
printf "%s\n" $right_up
fi
((columns++))
shift
done
while [ $height -lt $((height_cell+1)) ]
do
tput cup $((pos_y+height)) $pos_x
printf "%s\n" $ver
pos_x2=$pos_x
for loop_columns in \seq 1 $nb_cols
do
pos_x=$((pos_x+width_cell[$loop_columns]))
for loop in \seq 1 ${width_cell[$loop_columns]} ; do tput cup $((posy+height)) $((posx+$loopcolumns)) ; done`if [[ $cols -lt $nbcolumns ]] || [ $cols -gt 1 ] && [ $cols -lt $nb_columns ] || [ $cols -eq $nb_columns ] ; then
printf "%s\n" $ver
fi
done
((height++))
if [ $loop_columns -eq $nb_cols ] ; then posx=$posx2 ; fi
doneif [[ $rows -eq $nb_rows ]] ; thenleft_down=${border[4]} ; mid_down=${border[7]} ; right_down=${border[5]}elif [[ $rows -lt $nb_rows ]] ; thenleft_down=${border[6]} ; mid_down=${border[10]} ; right_down=${border[9]}fitput cup $((pos_y+height)) $pos_xprintf "%s" $left_downcols=1for loop_columns in \seq 1 $nbcols\```do`
for loop in \seq 1 ${widthcell$loop_columns}
; do printf "%s" $hor ; doneif [ $cols -lt $nb_cols ] ; then
printf "%s" $middown
elif [[ $cols -gt 1 ]] && [[ $cols -lt $nbcols ]] ; then
printf "%s" $middown
elif [[ $cols -eq $nbcols ]] ; then
printf "%s\n" $rightdown
fi
((cols++))
`done`
`echo`
`echo`
`tput sgr 0`
`}`
and here the command to call it :
drawarray 10 12 0 7 4 3 20 15 10 5 3 20 15 10 5 3
​
and the result :
╔════════════════════╦═══════════════╦══════════╦═════╗
║ ║ ║ ║. ║
║ ║ ║ ║. ║
║ ║ ║ ║. ║.
╠════════════════════╬═══════════════╬══════════╬═════╣
​
https://redd.it/z0daiu
@r_bash
reddit
Displaying datas in an array
Hello, I'm trying to draw an array for displaying datas. I succeeded for the first row with as many columns I want, but I have a trouble to draw...
invoke a function only if a filename is supplied?
I have a function which is basically an entire bash noscript, it'll run but not do anything unless a filename is provided,
how would I have it so it does something like
echo 'Nothing happened, filename must be supplied'
How do I go about this?
https://redd.it/z0pyzf
@r_bash
I have a function which is basically an entire bash noscript, it'll run but not do anything unless a filename is provided,
how would I have it so it does something like
echo 'Nothing happened, filename must be supplied'
How do I go about this?
https://redd.it/z0pyzf
@r_bash
reddit
invoke a function only if a filename is supplied?
I have a function which is basically an entire bash noscript, it'll run but not do anything unless a filename is provided, how would I have it so...