Why is this string comparation not working?
Hi, I'm trying to compare a md5 hash with one saved in a file, the result is that always the hashes are unqual, even when they are equal:
#!/bin/bash
checksum=$(ls <FOLDER> | md5sum)
lastchecksum=$(cat CHECKSUM)
if [ "$checksum" != "$lastchecksum" ]; then
echo -n $checksum > CHECKSUM
echo CHECKSUMS ARE UNEQUAL
fi
https://redd.it/15dj7z1
@r_bash
Hi, I'm trying to compare a md5 hash with one saved in a file, the result is that always the hashes are unqual, even when they are equal:
#!/bin/bash
checksum=$(ls <FOLDER> | md5sum)
lastchecksum=$(cat CHECKSUM)
if [ "$checksum" != "$lastchecksum" ]; then
echo -n $checksum > CHECKSUM
echo CHECKSUMS ARE UNEQUAL
fi
https://redd.it/15dj7z1
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
test for empty variable throws an error; why?
I have the following snippet which is supposed to be in `.profile`, executed on login:
# mount unmounted disks if found in system
userdisks=( $(find /dev/disk/by-uuid -type l) )
for disk in "${userdisks[@]}"
do
if [ -z $(findmnt "$disk") ]
then
udisksctl mount -b "$disk"
fi
done`
to look for unmounted disks in the system and mounts any it finds, but I get the following error:
-bash: [: too many arguments
for each (mounted?) disk in the system. What is the issue here? It's probably really easy, but I'm stumped at the moment.
An `echo $(findmnt "$disk") looks like this if it's mounted (variable not empty):
`TARGET SOURCE FSTYPE OPTIONS / /dev/mmcblk0p1 ext4 rw,noatime,errors=remount-ro,commit=600 /var/log.hdd /dev/mmcblk0p1[/var/log] ext4 rw,noatime,errors=remount-ro,commit=600
https://redd.it/15em5pj
@r_bash
I have the following snippet which is supposed to be in `.profile`, executed on login:
# mount unmounted disks if found in system
userdisks=( $(find /dev/disk/by-uuid -type l) )
for disk in "${userdisks[@]}"
do
if [ -z $(findmnt "$disk") ]
then
udisksctl mount -b "$disk"
fi
done`
to look for unmounted disks in the system and mounts any it finds, but I get the following error:
-bash: [: too many arguments
for each (mounted?) disk in the system. What is the issue here? It's probably really easy, but I'm stumped at the moment.
An `echo $(findmnt "$disk") looks like this if it's mounted (variable not empty):
`TARGET SOURCE FSTYPE OPTIONS / /dev/mmcblk0p1 ext4 rw,noatime,errors=remount-ro,commit=600 /var/log.hdd /dev/mmcblk0p1[/var/log] ext4 rw,noatime,errors=remount-ro,commit=600
https://redd.it/15em5pj
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
How to set each nested JSON property to parent property, slightly modified?
I have the following input JSON:
{
"copyToClipboardCmd": {
"type": "string"
},
"editPreset": {
"type": "string"
},
"edit": {
"type": "string"
},
"editAtLine": {
"type": "string"
},
"editAtLineAndWait": {
"type": "string"
},
"open": {
"type": "string"
},
"openLink": {
"type": "string"
}
}
I wanna add new
{
"copyToClipboardCmd": {
"noscript": "copy to clipboard cmd",
"type": "string"
},
"editPreset": {
"noscript": "edit preset",
"type": "string"
},
...
I use YQ currently.
https://redd.it/15f5g2u
@r_bash
I have the following input JSON:
{
"copyToClipboardCmd": {
"type": "string"
},
"editPreset": {
"type": "string"
},
"edit": {
"type": "string"
},
"editAtLine": {
"type": "string"
},
"editAtLineAndWait": {
"type": "string"
},
"open": {
"type": "string"
},
"openLink": {
"type": "string"
}
}
I wanna add new
noscript property for each object (containing type) which value has to be equal to parent key with each <upper-letter> replaced by space<lower-letter>. To make it clear, I need to get this:{
"copyToClipboardCmd": {
"noscript": "copy to clipboard cmd",
"type": "string"
},
"editPreset": {
"noscript": "edit preset",
"type": "string"
},
...
I use YQ currently.
https://redd.it/15f5g2u
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Curl command resulting in "argument list too long" error. How should I reformat my command?
Hi, everyone. As someone who has practically zero experience with APIs (or the curl command), I am struggling to understand how I should fix this error. I have tried different fixes that result in only more errors, although I wonder if it is my syntax that is causing the problems.
Essentially, I need to rewrite the code below so I don't get the "argument list too long" error. I will paste how it looks currently (changing some sensitive information to generic terms):
\-------------------------
curl --location --request POST 'https://oauth.site.com/api/SendCCDA' \\
\--header 'Authorization: 123456789' \\
\--header 'Content-Type: application/json' \\
\--data '"{\\"CCDABase64\\": \\"'"${baseCCDA}"'\\",\\"EncounterId\\": \\"'"${encounterRef}"'\\",\\"Denoscription\\": \\"CCDA for '"${givenName}"' '"${familyName}"'.\\",\\"EncounterDateTime\\": \\"'"${encounterDate}"'\\",\\"PhysicianName\\": \\"Admin\\",\\"ProviderId\\": \\"Admin\\",\\"PracticeId\\": \\"'"${locationArr[0\]}"'\\",\\"FacilityId\\": \\"'"${locationArr[0\]}"'\\",\\"CreatedBy\\": \\"User\\",\\"OrganizationId\\":\\"0\\" ,\\"PatientDetails\\": {\\"PatientID\\": \\"'"${patientDFN}"'\\",\\"MRN\\": \\"'"${patientDFN}"'\\",\\"FirstName\\": \\"'"${givenName}"'\\",\\"LastName\\": \\"'"${familyName}"'\\",\\"DoB\\": \\"'"${birthDate}"'\\",\\"Gender\\": \\"'"${gender}"'\\"}}"'
\------------------------
The idea of the command is that it sends a base64 converted version of a CCDA (xml file) to the identified server. As you can guess, the different variables (like encounterRef or givenName for example) are pulled from the CCDA with prior bash code and put in the proper place within the command.
The issue is with the baseCCDA variable; apparently it results in too much text and the curl command is canceled because of it. I know the command works because if I submit a shorter CCDA file, it works properly. Only when I try to submit a longer CCDA file do I get the error.
What would be the best way to rewrite this? All input is much appreciated. Thanks in advance.
https://redd.it/15fky3b
@r_bash
Hi, everyone. As someone who has practically zero experience with APIs (or the curl command), I am struggling to understand how I should fix this error. I have tried different fixes that result in only more errors, although I wonder if it is my syntax that is causing the problems.
Essentially, I need to rewrite the code below so I don't get the "argument list too long" error. I will paste how it looks currently (changing some sensitive information to generic terms):
\-------------------------
curl --location --request POST 'https://oauth.site.com/api/SendCCDA' \\
\--header 'Authorization: 123456789' \\
\--header 'Content-Type: application/json' \\
\--data '"{\\"CCDABase64\\": \\"'"${baseCCDA}"'\\",\\"EncounterId\\": \\"'"${encounterRef}"'\\",\\"Denoscription\\": \\"CCDA for '"${givenName}"' '"${familyName}"'.\\",\\"EncounterDateTime\\": \\"'"${encounterDate}"'\\",\\"PhysicianName\\": \\"Admin\\",\\"ProviderId\\": \\"Admin\\",\\"PracticeId\\": \\"'"${locationArr[0\]}"'\\",\\"FacilityId\\": \\"'"${locationArr[0\]}"'\\",\\"CreatedBy\\": \\"User\\",\\"OrganizationId\\":\\"0\\" ,\\"PatientDetails\\": {\\"PatientID\\": \\"'"${patientDFN}"'\\",\\"MRN\\": \\"'"${patientDFN}"'\\",\\"FirstName\\": \\"'"${givenName}"'\\",\\"LastName\\": \\"'"${familyName}"'\\",\\"DoB\\": \\"'"${birthDate}"'\\",\\"Gender\\": \\"'"${gender}"'\\"}}"'
\------------------------
The idea of the command is that it sends a base64 converted version of a CCDA (xml file) to the identified server. As you can guess, the different variables (like encounterRef or givenName for example) are pulled from the CCDA with prior bash code and put in the proper place within the command.
The issue is with the baseCCDA variable; apparently it results in too much text and the curl command is canceled because of it. I know the command works because if I submit a shorter CCDA file, it works properly. Only when I try to submit a longer CCDA file do I get the error.
What would be the best way to rewrite this? All input is much appreciated. Thanks in advance.
https://redd.it/15fky3b
@r_bash
Set default conda env for terminal, but not for system python use
Hi all. I'm running Linux Mint and do some development with Python. I successfully installed
My goal is to separate all my Python development stuff from the system default/global python, but I'm admittedly still a newbie when it comes to Python envs.
https://redd.it/15fpc7u
@r_bash
Hi all. I'm running Linux Mint and do some development with Python. I successfully installed
conda, and created my-env that I want bash to use when I open a terminal. Currently, whenever I start a terminal conda shows base as the active (default?) env. If I add `conda activate <my-env>` to my `.bashrc` file, would that mean the Python-based programs on my system would use my-env, or would they still use base to run?My goal is to separate all my Python development stuff from the system default/global python, but I'm admittedly still a newbie when it comes to Python envs.
https://redd.it/15fpc7u
@r_bash
Stack Overflow
How to change default Anaconda python environment
I've installed Anaconda and created two extra environments: py3k (which holds Python 3.3) and py34 (which holds Python 3.4). Besides those, I have a default environment named 'root' which the Anaco...
System Administration Scripts Linux
I have recently made a few noscripts in Bash, I would like you to take a look at them, any suggestions for improvement are welcome. I leave it here.
https://github.com/javisys/System-Administration-Scripts-Linux
https://redd.it/15g4ww4
@r_bash
I have recently made a few noscripts in Bash, I would like you to take a look at them, any suggestions for improvement are welcome. I leave it here.
https://github.com/javisys/System-Administration-Scripts-Linux
https://redd.it/15g4ww4
@r_bash
GitHub
GitHub - javisys/System-Administration-Scripts-Linux: Simple noscripts for system administration for Linux, later I will create another…
Simple noscripts for system administration for Linux, later I will create another one with Powershell also for Active Directory. - GitHub - javisys/System-Administration-Scripts-Linux: Simple noscript...
Weird Error in Sort
This is the weirdest thing I've experienced, and I'm half convinced I am going crazy.
I am using the sort command on a Linux Mint workstation:
sort (GNU coreutils) 8.32
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and Paul Eggert.
I want to sort a text file based on the third column, and to use a generic numeric sort (since this has floats in scientific notation).
So I run:
sort -g -k 3 input_file.txt > output_file.txt
And the file it returns is sorted based on the 1st column, and not the third.
I have also tried "sort -k3g", "sort --key=3 --general-numeric-sort", etc. all with the same effect.
I can run "sort -k 3" and then it runs sort based on the third column, but using string logic rather than generic numerals.
I have transferred the same text file to my OSX machine "2.3-Apple (154)" -- and it works fine. I have transferred it to another linux machine, running sort 8.22
sort (GNU coreutils) 8.22
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and Paul Eggert.
and it works fine again. I have literally copied the commands between the two machines, so I know I am running the same commands on the same files, and getting different answers.
What is going on? Did 8.32 break sort or change some structure for the commands in a way I don't know about?
https://redd.it/15ghwjh
@r_bash
This is the weirdest thing I've experienced, and I'm half convinced I am going crazy.
I am using the sort command on a Linux Mint workstation:
sort (GNU coreutils) 8.32
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and Paul Eggert.
I want to sort a text file based on the third column, and to use a generic numeric sort (since this has floats in scientific notation).
So I run:
sort -g -k 3 input_file.txt > output_file.txt
And the file it returns is sorted based on the 1st column, and not the third.
I have also tried "sort -k3g", "sort --key=3 --general-numeric-sort", etc. all with the same effect.
I can run "sort -k 3" and then it runs sort based on the third column, but using string logic rather than generic numerals.
I have transferred the same text file to my OSX machine "2.3-Apple (154)" -- and it works fine. I have transferred it to another linux machine, running sort 8.22
sort (GNU coreutils) 8.22
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and Paul Eggert.
and it works fine again. I have literally copied the commands between the two machines, so I know I am running the same commands on the same files, and getting different answers.
What is going on? Did 8.32 break sort or change some structure for the commands in a way I don't know about?
https://redd.it/15ghwjh
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
can i call a function from inside an IF or while?
eg.
if [ (myFunction "enter your number" 1 5) == 3 \]; then
echo "u entered 3"
OR--------
while (myFunction "enter your number" 1 5) != 3; do
echo "incorrect"
done
https://redd.it/15gt5ho
@r_bash
eg.
if [ (myFunction "enter your number" 1 5) == 3 \]; then
echo "u entered 3"
OR--------
while (myFunction "enter your number" 1 5) != 3; do
echo "incorrect"
done
https://redd.it/15gt5ho
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Is it the most effective way to add new keys and sort them?
I have the following JSON input:
{
"copyToClipboardCmd": {
"type": "string"
},
"editPreset": {
"type": "string"
},
"edit": {
"type": "string"
},
"editAtLine": {
"type": "string"
},
"editAtLineAndWait": {
"type": "string"
},
"open": {
"type": "string"
},
"openLink": {
"type": "string"
}
}`
and my goal is to add `noscript` and `denoscription` properties to all objects and then sort keys in the following order: `noscript`, `denoscription`, `type`.
I've wrote the following jq noscript:
with_entries(.value.noscript = (.key | sub("(?<a>[A-Z])"; " \(.a)"; "g") | ascii_downcase)) |
with_entries(.value.denoscription = .value.noscript + "\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default") |
with_entries(.value = { noscript: .value.noscript, denoscription: .value.denoscription, type: .value.type })
It does what I want to do:
{
"copyToClipboardCmd": {
"noscript": "copy to clipboard cmd",
"denoscription": "copy to clipboard cmd\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default",
"type": "string"
},
"editPreset": {
"noscript": "edit preset",
"denoscription": "edit preset\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default",
"type": "string"
},
"edit": {
"noscript": "edit",
"denoscription": "edit\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default",
"type": "string"
},
"editAtLine": {
"noscript": "edit at line",
"denoscription": "edit at line\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default",
"type": "string"
},
"editAtLineAndWait": {
"noscript": "edit at line and wait",
"denoscription": "edit at line and wait\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default",
"type": "string"
},
"open": {
"noscript": "open",
"denoscription": "open\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default",
"type": "string"
},
"openLink": {
"noscript": "open link",
"denoscription": "open link\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default",
"type": "string"
}
}
, but I am curious whether it's the best (the shortest) way to do it. I had another idea to write something like this:
with_entries(.value.noscript = (.key | sub("(?<a>[A-Z])"; " \(.a)"; "g") | ascii_downcase)) |
.[] | .denoscription = .noscript + "\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default" |
{ noscript, denoscription, type }
But I have trouble in joining all those objects into a one big object: I've tried to wrap all code inside `{...}` but got an error:
jq: error: syntax error, unexpected '(', expecting '}' (Unix shell quoting issues?) at <top-level>, line 1:
{with_entries(.value.noscript = (.key | sub("(?<a>[A-Z])"; " \(.a)"; "g") | ascii_downcase)) |
jq: error: syntax error, unexpected '}', expecting $end (Unix shell quoting issues?) at <top-level>, line 3:
{ noscript, denoscription, type }}
jq: 2 compile errors
So... I guess my question is how to wrap several objects into a root one?
https://redd.it/15gwlbd
@r_bash
I have the following JSON input:
{
"copyToClipboardCmd": {
"type": "string"
},
"editPreset": {
"type": "string"
},
"edit": {
"type": "string"
},
"editAtLine": {
"type": "string"
},
"editAtLineAndWait": {
"type": "string"
},
"open": {
"type": "string"
},
"openLink": {
"type": "string"
}
}`
and my goal is to add `noscript` and `denoscription` properties to all objects and then sort keys in the following order: `noscript`, `denoscription`, `type`.
I've wrote the following jq noscript:
with_entries(.value.noscript = (.key | sub("(?<a>[A-Z])"; " \(.a)"; "g") | ascii_downcase)) |
with_entries(.value.denoscription = .value.noscript + "\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default") |
with_entries(.value = { noscript: .value.noscript, denoscription: .value.denoscription, type: .value.type })
It does what I want to do:
{
"copyToClipboardCmd": {
"noscript": "copy to clipboard cmd",
"denoscription": "copy to clipboard cmd\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default",
"type": "string"
},
"editPreset": {
"noscript": "edit preset",
"denoscription": "edit preset\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default",
"type": "string"
},
"edit": {
"noscript": "edit",
"denoscription": "edit\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default",
"type": "string"
},
"editAtLine": {
"noscript": "edit at line",
"denoscription": "edit at line\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default",
"type": "string"
},
"editAtLineAndWait": {
"noscript": "edit at line and wait",
"denoscription": "edit at line and wait\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default",
"type": "string"
},
"open": {
"noscript": "open",
"denoscription": "open\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default",
"type": "string"
},
"openLink": {
"noscript": "open link",
"denoscription": "open link\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default",
"type": "string"
}
}
, but I am curious whether it's the best (the shortest) way to do it. I had another idea to write something like this:
with_entries(.value.noscript = (.key | sub("(?<a>[A-Z])"; " \(.a)"; "g") | ascii_downcase)) |
.[] | .denoscription = .noscript + "\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default" |
{ noscript, denoscription, type }
But I have trouble in joining all those objects into a one big object: I've tried to wrap all code inside `{...}` but got an error:
jq: error: syntax error, unexpected '(', expecting '}' (Unix shell quoting issues?) at <top-level>, line 1:
{with_entries(.value.noscript = (.key | sub("(?<a>[A-Z])"; " \(.a)"; "g") | ascii_downcase)) |
jq: error: syntax error, unexpected '}', expecting $end (Unix shell quoting issues?) at <top-level>, line 3:
{ noscript, denoscription, type }}
jq: 2 compile errors
So... I guess my question is how to wrap several objects into a root one?
https://redd.it/15gwlbd
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Started learning bash
Hi everyone today I started learning bash with no prior knowledge.I’m excited but also moving at a realistic pace so I don’t feel overwhelmed. I’m currently watching the Microsoft developer series (Bash for beginners)on YT.If you have any tips and advices for me I’ll be happy to accept them.
https://redd.it/15h1sd0
@r_bash
Hi everyone today I started learning bash with no prior knowledge.I’m excited but also moving at a realistic pace so I don’t feel overwhelmed. I’m currently watching the Microsoft developer series (Bash for beginners)on YT.If you have any tips and advices for me I’ll be happy to accept them.
https://redd.it/15h1sd0
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Github noobie (somewhat bash related)
I want to make my bash scrips available so I created a github profile and uploaded some noscripts to a public repo.
Here comes the issue:
I can't just git clone a noscript from inside the terminal without being asked for authentication. How do I taggle this? I'd like to be able to just git clone without any further ado. I don't mind to have the noscripts available for everybody.
I know, pretty noob question...
https://redd.it/15h8l4x
@r_bash
I want to make my bash scrips available so I created a github profile and uploaded some noscripts to a public repo.
Here comes the issue:
I can't just git clone a noscript from inside the terminal without being asked for authentication. How do I taggle this? I'd like to be able to just git clone without any further ado. I don't mind to have the noscripts available for everybody.
I know, pretty noob question...
https://redd.it/15h8l4x
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Array not populating in bash noscript ?
Here is a link to my bash noscript that I am working on , as long with a text file and awk file that I use with the noscript.
https://pastebin.com/xTGyk5su
For what ever reason my quotawheels array is not being populated and I cant figure out why ? If anyone can help , I would really appreciate it.
https://redd.it/15hhgek
@r_bash
Here is a link to my bash noscript that I am working on , as long with a text file and awk file that I use with the noscript.
https://pastebin.com/xTGyk5su
For what ever reason my quotawheels array is not being populated and I cant figure out why ? If anyone can help , I would really appreciate it.
https://redd.it/15hhgek
@r_bash
Pastebin
noscripthelp - 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.
need to extract stats from a webpage
ive used wget to download a url. so i have a html file. i need to extract all these stats fromthe text in it and tabulate them. i don't think the sed command can do that?
https://redd.it/15hl0v1
@r_bash
ive used wget to download a url. so i have a html file. i need to extract all these stats fromthe text in it and tabulate them. i don't think the sed command can do that?
https://redd.it/15hl0v1
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Bash History full of garbage
Hi All,
Linux Mint 21.2 Victoria -- Cinnamon
Below I copied a small chunk of the random stuff in my bash history, anyone know what is creating all this?
Thanks, Joe
===============
091 cd "`printf '%b' '\\0057mnt\\0057usb128\\0057backup\\0057current\\0057\\0056config\\0057nvim'`"
1092 cd "`printf '%b' '\\0057mnt\\0057usb128\\0057backup\\0057current\\0057\\0056config\\0057nvim\\0057lua'`"
1093 cd "`printf '%b' '\\0057mnt\\0057usb128\\0057backup\\0057current\\0057\\0056config\\0057nvim\\0057lua\\0057core'`"
1094 cd "`printf '%b' '\\0057mnt\\0057usb128\\0057backup\\0057current\\0057\\0056config\\0057nvim\\0057lua\\0057core\\0057plugin\\0137config'`"
1110 mc_print_command_buffer () { printf "%s\\\\n" "$READLINE_LINE" >\&12; }
1114 cd "`printf '%b' '\\0057home\\0057joe\\0057\\0056vim\\0057spell'`"
1115 cd "`printf '%b' '\\0057home\\0057joe\\0057\\0056vim'`"
1117 mc_print_command_buffer () { printf "%s\\\\n" "$READLINE_LINE" >\&12; }
1121 cd "`printf '%b' '\\0057usr\\0057share\\0057vim\\0057vim82'`"
1130 cd "`printf '%b' '\\0057usr\\0057share\\0057vim\\0057vim82\\0057spell'`"
1132 cd "`printf '%b' '\\0057usr\\0057share\\0057vim\\0057vim82'`"
1133 cd "`printf '%b' '\\0057usr\\0057share\\0057vim'`"
1134 cd "`printf '%b' '\\0057usr\\0057share'`"
1135 cd "`printf '%b' '\\0057usr'`"
1136 cd "`printf '%b' '\\0057'`"
1137 cd "`printf '%b' '\\0057usr\\0057share\\0057vim\\0057vim82\\0057spell'`"
1138 mc_print_command_buffer () { printf "%s\\\\n" "$READLINE_LINE" >\&12; }
1142 cd "`printf '%b' '\\0057home\\0057joe\\0057\\0056vim'`"
1789 cd "`printf '%b' '\\0057home\\0057joe\\0057VirtualBox\\0137VMs\\0057Debian12'`"
1790 cd "`printf '%b' '\\0057home\\0057joe\\0057VirtualBox\\0137VMs\\0057Debian12\\0057Logs'`"
1833 mc_print_command_buffer () { printf "%s\\\\n" "$READLINE_LINE" >\&12; }
1837 cd "`printf '%b' '\\0057home\\0057joe\\0057\\0056local\\0057kitty\\0056app\\0057share\\0057applications'`"
1838 cd "`printf '%b' '\\0057home\\0057joe\\0057\\0056local\\0057kitty\\0056app\\0057share\\0057doc\\0057kitty\\0057html'`"
1839 cd "`printf '%b' '\\0057home\\0057joe\\0057\\0056local\\0057kitty\\0056app\\0057share\\0057doc\\0057kitty'`"
1840 cd "`printf '%b' '\\0057home\\0057joe\\0057\\0056local\\0057kitty\\0056app\\0057share\\0057doc'`"
1841 cd "`printf '%b' '\\0057home\\0057joe\\0057\\0056local\\0057kitty\\0056app\\0057share'`"
​
​
https://redd.it/15hnoe4
@r_bash
Hi All,
Linux Mint 21.2 Victoria -- Cinnamon
Below I copied a small chunk of the random stuff in my bash history, anyone know what is creating all this?
Thanks, Joe
===============
091 cd "`printf '%b' '\\0057mnt\\0057usb128\\0057backup\\0057current\\0057\\0056config\\0057nvim'`"
1092 cd "`printf '%b' '\\0057mnt\\0057usb128\\0057backup\\0057current\\0057\\0056config\\0057nvim\\0057lua'`"
1093 cd "`printf '%b' '\\0057mnt\\0057usb128\\0057backup\\0057current\\0057\\0056config\\0057nvim\\0057lua\\0057core'`"
1094 cd "`printf '%b' '\\0057mnt\\0057usb128\\0057backup\\0057current\\0057\\0056config\\0057nvim\\0057lua\\0057core\\0057plugin\\0137config'`"
1110 mc_print_command_buffer () { printf "%s\\\\n" "$READLINE_LINE" >\&12; }
1114 cd "`printf '%b' '\\0057home\\0057joe\\0057\\0056vim\\0057spell'`"
1115 cd "`printf '%b' '\\0057home\\0057joe\\0057\\0056vim'`"
1117 mc_print_command_buffer () { printf "%s\\\\n" "$READLINE_LINE" >\&12; }
1121 cd "`printf '%b' '\\0057usr\\0057share\\0057vim\\0057vim82'`"
1130 cd "`printf '%b' '\\0057usr\\0057share\\0057vim\\0057vim82\\0057spell'`"
1132 cd "`printf '%b' '\\0057usr\\0057share\\0057vim\\0057vim82'`"
1133 cd "`printf '%b' '\\0057usr\\0057share\\0057vim'`"
1134 cd "`printf '%b' '\\0057usr\\0057share'`"
1135 cd "`printf '%b' '\\0057usr'`"
1136 cd "`printf '%b' '\\0057'`"
1137 cd "`printf '%b' '\\0057usr\\0057share\\0057vim\\0057vim82\\0057spell'`"
1138 mc_print_command_buffer () { printf "%s\\\\n" "$READLINE_LINE" >\&12; }
1142 cd "`printf '%b' '\\0057home\\0057joe\\0057\\0056vim'`"
1789 cd "`printf '%b' '\\0057home\\0057joe\\0057VirtualBox\\0137VMs\\0057Debian12'`"
1790 cd "`printf '%b' '\\0057home\\0057joe\\0057VirtualBox\\0137VMs\\0057Debian12\\0057Logs'`"
1833 mc_print_command_buffer () { printf "%s\\\\n" "$READLINE_LINE" >\&12; }
1837 cd "`printf '%b' '\\0057home\\0057joe\\0057\\0056local\\0057kitty\\0056app\\0057share\\0057applications'`"
1838 cd "`printf '%b' '\\0057home\\0057joe\\0057\\0056local\\0057kitty\\0056app\\0057share\\0057doc\\0057kitty\\0057html'`"
1839 cd "`printf '%b' '\\0057home\\0057joe\\0057\\0056local\\0057kitty\\0056app\\0057share\\0057doc\\0057kitty'`"
1840 cd "`printf '%b' '\\0057home\\0057joe\\0057\\0056local\\0057kitty\\0056app\\0057share\\0057doc'`"
1841 cd "`printf '%b' '\\0057home\\0057joe\\0057\\0056local\\0057kitty\\0056app\\0057share'`"
​
​
https://redd.it/15hnoe4
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Need to return the largest set
Hey all, I'm writing a noscript to query an endpoint that returns a list of groups and members. That's fine but is there a way that I can parse that list to just return the group with the largest membership?
https://redd.it/15hz5zf
@r_bash
Hey all, I'm writing a noscript to query an endpoint that returns a list of groups and members. That's fine but is there a way that I can parse that list to just return the group with the largest membership?
https://redd.it/15hz5zf
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Read function and many options
hey guys I am working lately on automated noscript that create file with variety extension and I came across with the needs to use read function with many option
and I am sure it C but why ?
https://redd.it/15i8omu
@r_bash
hey guys I am working lately on automated noscript that create file with variety extension and I came across with the needs to use read function with many option
# which one of these will work
A) read -are Pyfiles
B) read -a -r -e Pyfiles
C) or none of these and if so why?
and I am sure it C but why ?
https://redd.it/15i8omu
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
What's wrong with my noscript?
I am not ashamed to say that I am a bit of a noscript monkey when it comes to writing noscripts for bash; so I am probably doing something simple wrong.
I want to have a noscript that does a simple daily backup and then remove backups that are older than seven days old. I can see that the backup element works, but the removal of existing backups does not.
#!/bin/bash -e
# backup folder
destination_folder="/home/[folder]/backup/drupal/$(date +%F)"
archive_file="backup-$(date +%H%M).tar.gz"
rotate=7
mkdir -p "$destination_folder"
# backup
/bin/tar --exclude='/home/[folder]/backup' -Oczf "$destination_folder/$archive_file" /var/www/html/[site folder]/
# attempt delete older than 7 days
find /home/[folder]/backup/drupal/ -name '*.tar.gz' -mtime +6 -exec rm -rf {} \;
Would appreciate a fresh pair of eyes - I even tried to move the find and remove to a separate file (and tried rewriting it) to try and fix it, without success.
https://redd.it/15jib6f
@r_bash
I am not ashamed to say that I am a bit of a noscript monkey when it comes to writing noscripts for bash; so I am probably doing something simple wrong.
I want to have a noscript that does a simple daily backup and then remove backups that are older than seven days old. I can see that the backup element works, but the removal of existing backups does not.
#!/bin/bash -e
# backup folder
destination_folder="/home/[folder]/backup/drupal/$(date +%F)"
archive_file="backup-$(date +%H%M).tar.gz"
rotate=7
mkdir -p "$destination_folder"
# backup
/bin/tar --exclude='/home/[folder]/backup' -Oczf "$destination_folder/$archive_file" /var/www/html/[site folder]/
# attempt delete older than 7 days
find /home/[folder]/backup/drupal/ -name '*.tar.gz' -mtime +6 -exec rm -rf {} \;
Would appreciate a fresh pair of eyes - I even tried to move the find and remove to a separate file (and tried rewriting it) to try and fix it, without success.
https://redd.it/15jib6f
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Script to Automatically Start a glassfish domain once it's down?
Steps to reproduce this issue:
1) Glassfish domain called domain1 goes down.
2) Now, start that domain again.
Algorithm like this should exist:
if(domain1 is down)
{
path/to/asadmin start-domain domain1
}
How do I check if domain1 is down or not?
Assume there are multiple domains, around 8 of them And different servers have varying amount of domains.
My pseudocode:
domainarray= get list of all domains in an array
for(i=0;i<domainarray.length;i++)
{
if(path/to/asadmin stop-domain domainarray[i]==0) //assuming exit code 0 returns if the domain is already stopped
{
path/to/asadmin start-domain domainarrayi;
}
}
Problems with my code:
I might be attempting to stop an unstopped domain which is very bad.
Is there an equivalent of
Sources: https://glassfish.org/docs/5.1.0/administration-guide/domains.html#giurs
https://www.freedesktop.org/software/systemd/man/systemd.service.html
https://redd.it/15jl0cu
@r_bash
Steps to reproduce this issue:
1) Glassfish domain called domain1 goes down.
2) Now, start that domain again.
Algorithm like this should exist:
if(domain1 is down)
{
path/to/asadmin start-domain domain1
}
How do I check if domain1 is down or not?
Assume there are multiple domains, around 8 of them And different servers have varying amount of domains.
My pseudocode:
domainarray= get list of all domains in an array
for(i=0;i<domainarray.length;i++)
{
if(path/to/asadmin stop-domain domainarray[i]==0) //assuming exit code 0 returns if the domain is already stopped
{
path/to/asadmin start-domain domainarrayi;
}
}
Problems with my code:
I might be attempting to stop an unstopped domain which is very bad.
Is there an equivalent of
systemctl is-active servicename for glassfish domains?Sources: https://glassfish.org/docs/5.1.0/administration-guide/domains.html#giurs
https://www.freedesktop.org/software/systemd/man/systemd.service.html
https://redd.it/15jl0cu
@r_bash
Script to send an alert mail once the disk space is above 90% sends disk full even when the disk isn't full, how to resolve this issue?
#!/bin/bash
df -m > myfile
server_ip_address=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1)
if awk '$2 > 10000 && $5 > 90' myfile ; then
echo "Disk Full in $server_ip_address"
else
echo "Nothing wrong with the server"
fi
When I execute the noscript, always get disk full as output?
Output of df -m looks like this:
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/mapper/centos-root 949305 512827 436479 55% /
devtmpfs 3811 0 3811 0% /dev
tmpfs 3823 0 3823 0% /dev/abc
tmpfs 3823 18 3806 1% /run
tmpfs 3823 0 3823 0% /sys/fs/cgroup
/dev/sda2 1014 175 840 18% /boot
/dev/sda1 1022 12 1011 2% /boot/efi
tmpfs 765 0 765 0% /run/user/2000
The outut of df -m differs from server to server. I am thus comparing if Size>10GB and Use%>90%. As some disk with size<10GB may not be important to be under 90% disk usage.
**Update 1:**
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
OS is centos 7
Problem with the current code:
I need to compare the second row's columns, but my current code is comparing the first rows columns, that's why I suppose it's not working. How to resolve the issue?
https://redd.it/15jkztg
@r_bash
#!/bin/bash
df -m > myfile
server_ip_address=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1)
if awk '$2 > 10000 && $5 > 90' myfile ; then
echo "Disk Full in $server_ip_address"
else
echo "Nothing wrong with the server"
fi
When I execute the noscript, always get disk full as output?
Output of df -m looks like this:
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/mapper/centos-root 949305 512827 436479 55% /
devtmpfs 3811 0 3811 0% /dev
tmpfs 3823 0 3823 0% /dev/abc
tmpfs 3823 18 3806 1% /run
tmpfs 3823 0 3823 0% /sys/fs/cgroup
/dev/sda2 1014 175 840 18% /boot
/dev/sda1 1022 12 1011 2% /boot/efi
tmpfs 765 0 765 0% /run/user/2000
The outut of df -m differs from server to server. I am thus comparing if Size>10GB and Use%>90%. As some disk with size<10GB may not be important to be under 90% disk usage.
**Update 1:**
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
OS is centos 7
Problem with the current code:
I need to compare the second row's columns, but my current code is comparing the first rows columns, that's why I suppose it's not working. How to resolve the issue?
https://redd.it/15jkztg
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community