cron delete command help
Hi all,
​
I am running this manual command to delete a kubernetes pod
kubectl delete pod -n testing-namespace tunnel-displace-665121cf-8c71y
pod "tunnel-displace-665121cf-8c71y" deleted
I was wondering is there a way to set it up in a cron job noscript or one liner to delete it, bear in mind that the pods ending name '665121cf-8c71y' constantly changes when deleted and a new one is spun up.
https://redd.it/xwa1so
@r_bash
Hi all,
​
I am running this manual command to delete a kubernetes pod
kubectl delete pod -n testing-namespace tunnel-displace-665121cf-8c71y
pod "tunnel-displace-665121cf-8c71y" deleted
I was wondering is there a way to set it up in a cron job noscript or one liner to delete it, bear in mind that the pods ending name '665121cf-8c71y' constantly changes when deleted and a new one is spun up.
https://redd.it/xwa1so
@r_bash
reddit
cron delete command help
Hi all, I am running this manual command to delete a kubernetes pod kubectl delete pod -n testing-namespace...
Help with recovering files in vim
I was working on a file in vim and I press :wq, I closed, but when I opened it again, I loaded stuff form some swap file (from 6 hours ago) so I lost all of my data.
I tried vim recover, but still, its loading only from the swap file from 6 hours ago.
Is there any way I can recover my data?
(Anything will work, like when I scroll up on my terminal, I can see prev data, but I does not go up to the point where I was working on my file, is there any way I can see my data this way atleatst?)
​
Any help will be appreciated (I have to submit an assignment in 6hrs and all my data was on that file I lost)
https://redd.it/xwa0o1
@r_bash
I was working on a file in vim and I press :wq, I closed, but when I opened it again, I loaded stuff form some swap file (from 6 hours ago) so I lost all of my data.
I tried vim recover, but still, its loading only from the swap file from 6 hours ago.
Is there any way I can recover my data?
(Anything will work, like when I scroll up on my terminal, I can see prev data, but I does not go up to the point where I was working on my file, is there any way I can see my data this way atleatst?)
​
Any help will be appreciated (I have to submit an assignment in 6hrs and all my data was on that file I lost)
https://redd.it/xwa0o1
@r_bash
reddit
Help with recovering files in vim
I was working on a file in vim and I press :wq, I closed, but when I opened it again, I loaded stuff form some swap file (from 6 hours ago) so I...
Please how can I fix this Linux Bash related error?
For context, I am currently undergoing a Software Engineering program for full stack dev training, and I am currently exploring basics of shell with some questions to be answered at the end of my study of the basics and concepts. I am doing very ok with it considering my background in Computer Engineering, but a final question here has me stumped.
Question - Create a magic file school.mgc that can be used with the command file to detect School data files. School data files always contain the string SCHOOL at offset 0.
Below is the command I used on bash to key in the noscript into the file school.mgc
echo -e '0 string SCHOOL School data\n!:mime School' > school.mgc
But when the software program autochecker runs through my answer, I get the error msg below.
*\*\[Got\]*
*(0 chars long)*
*\[Expected\] 0-current\_working\_directory: text/plain 100-lets\_move: text/plain 101-clean\_emacs: text/plain 102-tree: text/plain 103-commas: text/plain 10-back: text/plain 11-lists: text/plain 12-file\_type: text/plain 13-symbolic\_link: text/plain 14-copy\_html: text/plain 1-listit: text/plain 2-bring\_me\_home: text/plain 3-listfiles: text/plain 4-listmorefiles: text/plain 5-listfilesdigitonly: text/plain 6-firstdirectory: text/plain 7-movethatfile: text/plain 8-firstdelete: text/plain 9-firstdirdeletion: text/plain fake\_school0: text/plain fake\_school1: text/plain file\_school0: School file\_school1: School file\_test0: inode/x-empty h\_school.mgc: application/octet-stream README.md: ... (2168 chars long)\**
​
**I am assuming something is wrong with my noscript in school.mgc. Can someone please assist and point me in the right direction please?**
**Thanks.**
https://redd.it/xw8cdb
@r_bash
For context, I am currently undergoing a Software Engineering program for full stack dev training, and I am currently exploring basics of shell with some questions to be answered at the end of my study of the basics and concepts. I am doing very ok with it considering my background in Computer Engineering, but a final question here has me stumped.
Question - Create a magic file school.mgc that can be used with the command file to detect School data files. School data files always contain the string SCHOOL at offset 0.
Below is the command I used on bash to key in the noscript into the file school.mgc
echo -e '0 string SCHOOL School data\n!:mime School' > school.mgc
But when the software program autochecker runs through my answer, I get the error msg below.
*\*\[Got\]*
*(0 chars long)*
*\[Expected\] 0-current\_working\_directory: text/plain 100-lets\_move: text/plain 101-clean\_emacs: text/plain 102-tree: text/plain 103-commas: text/plain 10-back: text/plain 11-lists: text/plain 12-file\_type: text/plain 13-symbolic\_link: text/plain 14-copy\_html: text/plain 1-listit: text/plain 2-bring\_me\_home: text/plain 3-listfiles: text/plain 4-listmorefiles: text/plain 5-listfilesdigitonly: text/plain 6-firstdirectory: text/plain 7-movethatfile: text/plain 8-firstdelete: text/plain 9-firstdirdeletion: text/plain fake\_school0: text/plain fake\_school1: text/plain file\_school0: School file\_school1: School file\_test0: inode/x-empty h\_school.mgc: application/octet-stream README.md: ... (2168 chars long)\**
​
**I am assuming something is wrong with my noscript in school.mgc. Can someone please assist and point me in the right direction please?**
**Thanks.**
https://redd.it/xw8cdb
@r_bash
reddit
Please how can I fix this Linux Bash related error?
For context, I am currently undergoing a Software Engineering program for full stack dev training, and I am currently exploring basics of shell...
Looking for help with montage issues “montage: UnableToOpenConfigurefile” “montage: NoDecodeDelegateForThisImageFormat”
https://redd.it/xwk022
@r_bash
https://redd.it/xwk022
@r_bash
Docker writing to program STDIN after starting it up?
Hi! I'm trying to set up a docker container that runs a steamcmd server.
It's all working fine, the server is downloaded an executed correctly. But it's the first time that i stumble upon this roadblock.
The first time that the server starts it asks for an admin password - that cannot be set as an argument or environment variable - that it reads from stdin.
My startup.sh noscript looks like this
#!/bin/bash
echo "Starting"
steamcmd +runnoscript /server/steam-noscript.txt
start-server.sh -servername server
When the server starts it complains that no password could be read
LOG> Command line admin password: null
LOG> Enter new administrator password:
Exception in thread "main" ERROR: General ,
1665004316009> 10,911,614> java.util.NoSuchElementException: No line found
How can i write some password to the stdin before the process starts?
https://redd.it/xwmmb1
@r_bash
Hi! I'm trying to set up a docker container that runs a steamcmd server.
It's all working fine, the server is downloaded an executed correctly. But it's the first time that i stumble upon this roadblock.
The first time that the server starts it asks for an admin password - that cannot be set as an argument or environment variable - that it reads from stdin.
My startup.sh noscript looks like this
#!/bin/bash
echo "Starting"
steamcmd +runnoscript /server/steam-noscript.txt
start-server.sh -servername server
When the server starts it complains that no password could be read
LOG> Command line admin password: null
LOG> Enter new administrator password:
Exception in thread "main" ERROR: General ,
1665004316009> 10,911,614> java.util.NoSuchElementException: No line found
How can i write some password to the stdin before the process starts?
https://redd.it/xwmmb1
@r_bash
reddit
[Docker] writing to program STDIN after starting it up?
Hi! I'm trying to set up a docker container that runs a steamcmd server. It's all working fine, the server is downloaded an executed correctly....
This media is not supported in your browser
VIEW IN TELEGRAM
arttime's v1.9.1 brings joy to sysadmins and power-users by enabling the use of arttime right after booting OS for the first time and installing zsh (i.e. in a very limited terminal environment). More denoscription and links in comment below.
https://redd.it/xwqgl0
@r_bash
https://redd.it/xwqgl0
@r_bash
Here’s a playlist of 7 hours of music I use to focus when I’m coding/studying. Post yours as well if you also have one!
https://open.spotify.com/playlist/3gk5HsGrGwKQTHinbuPgRE
https://redd.it/xwtbca
@r_bash
https://open.spotify.com/playlist/3gk5HsGrGwKQTHinbuPgRE
https://redd.it/xwtbca
@r_bash
Spotify
Coding Synth 2
tealc · Playlist · 99 songs · 301 likes
I trying to write a noscript that created a number of files, each containing facts about specific people
I’m trying to write a noscript where the expected result is a noscript that takes a file, reads the people names, and creates several files named “facts-PERSON.txt”, for example “facts-mari.txt”, “facts-ole.txt”.
Each of these generated files must contain:
*On the first line, the name of the person.
*Then, all “fact lines” that contain that persons’s name, one line per fact.
*On the last line, the number of facts about that person.
Basic example for "john" with filename "facts-john.txt":
john
John has a farm.
Mari loves John.
In the last 10 years, John went to Sweden only once.
3
I have a file called filteredlist.txt with all the names, and a file called factlist.txt with all the fact about the people.
I have used:
for name in ‘cat filteredlist.txt; do touch — facts-$name.txt; done
To create files for each person, but I don’t know how to move the facts from the other file into the persons file and the word count at the end.
I have tried:
cat filteredlist.txt factlist.txt | grep -i -E $name >> facts-$name.txt
and
cat facts-$name.txt | wc -l $1 | awk '{print $1 - 1}'n >> facts-$name.txt
But they don’t work, they just work on the first name, not the rest.
https://redd.it/xx5h8i
@r_bash
I’m trying to write a noscript where the expected result is a noscript that takes a file, reads the people names, and creates several files named “facts-PERSON.txt”, for example “facts-mari.txt”, “facts-ole.txt”.
Each of these generated files must contain:
*On the first line, the name of the person.
*Then, all “fact lines” that contain that persons’s name, one line per fact.
*On the last line, the number of facts about that person.
Basic example for "john" with filename "facts-john.txt":
john
John has a farm.
Mari loves John.
In the last 10 years, John went to Sweden only once.
3
I have a file called filteredlist.txt with all the names, and a file called factlist.txt with all the fact about the people.
I have used:
for name in ‘cat filteredlist.txt; do touch — facts-$name.txt; done
To create files for each person, but I don’t know how to move the facts from the other file into the persons file and the word count at the end.
I have tried:
cat filteredlist.txt factlist.txt | grep -i -E $name >> facts-$name.txt
and
cat facts-$name.txt | wc -l $1 | awk '{print $1 - 1}'n >> facts-$name.txt
But they don’t work, they just work on the first name, not the rest.
https://redd.it/xx5h8i
@r_bash
reddit
I trying to write a noscript that created a number of files, each...
I’m trying to write a noscript where the expected result is a noscript that takes a file, reads the people names, and creates several files named...
Needing Help with a File Extraction Script for my Dad
Hi everyone -
My dad archived old family photos and documents as ISO’s and has them saved to an old network hard drive back up. I don’t know why he did it this way but he has seemingly thousands of ISOs made for every album or folder the photos and documents belonged in. Decades worth of things I am trying to extract for him.
He doesn’t trust any programs out there to extract the files within the ISOs as he is worried it would give the company access to his family photos. In his words, he wants “the computer to handle it”… aka “me”.
I am hoping to not have to open each one to extract data but instead have a noscript mount the ISO, extract the data, (Unmount?) and move onto the next ISO automatically. Or even accomplish data extracting without needing to mount the ISO works as well. He put in a lot of work organizing the folders and files before saving as an ISO, so I am hoping it keeps its naming structure so he doesn’t have to do that again.
I am currently in possession of his networked hard drive but it sometimes loses its connection when trying to access via USB due to a loose cable connection, so hoping to see if this can be done on a networked drive and if there are failures is there a log that can tell me the files it couldn’t extract? I just don’t want to accidentally miss one or two.
I hope this is enough information and not too large of an ask. I want to try to get this done for an upcoming family reunion this thanksgiving and surprise him.
Thank you everyone for any guidance you can give. Can a noscript even accomplish this and is there anyone kind enough to assist? It would mean the world to me.
https://redd.it/xx8hf5
@r_bash
Hi everyone -
My dad archived old family photos and documents as ISO’s and has them saved to an old network hard drive back up. I don’t know why he did it this way but he has seemingly thousands of ISOs made for every album or folder the photos and documents belonged in. Decades worth of things I am trying to extract for him.
He doesn’t trust any programs out there to extract the files within the ISOs as he is worried it would give the company access to his family photos. In his words, he wants “the computer to handle it”… aka “me”.
I am hoping to not have to open each one to extract data but instead have a noscript mount the ISO, extract the data, (Unmount?) and move onto the next ISO automatically. Or even accomplish data extracting without needing to mount the ISO works as well. He put in a lot of work organizing the folders and files before saving as an ISO, so I am hoping it keeps its naming structure so he doesn’t have to do that again.
I am currently in possession of his networked hard drive but it sometimes loses its connection when trying to access via USB due to a loose cable connection, so hoping to see if this can be done on a networked drive and if there are failures is there a log that can tell me the files it couldn’t extract? I just don’t want to accidentally miss one or two.
I hope this is enough information and not too large of an ask. I want to try to get this done for an upcoming family reunion this thanksgiving and surprise him.
Thank you everyone for any guidance you can give. Can a noscript even accomplish this and is there anyone kind enough to assist? It would mean the world to me.
https://redd.it/xx8hf5
@r_bash
reddit
Needing Help with a File Extraction Script for my Dad
Hi everyone - My dad archived old family photos and documents as ISO’s and has them saved to an old network hard drive back up. I don’t know why...
Opinions on the right tool
Hi Everybody! (Hi Dr. Nick!)
What I like about this subreddit is that while it's bash focused, it's not generally populated with bash zealots or bash absolutists. What I've seen over a number of posts is more of an approach of "Right tool for the right job". So with that in mind I want to explain my problem/desired outcome and get your opinions on what the right tool is for this.
Problem: (Better) Websites will provide you with the file hash for the file you're downloading so you can verify authenticity/integrity when you have it on your system. My eyes are lazy. When I'm verifying a hash I simply make sure the last 6 or so characters match between the two files. My eyes are also assholes and like to tell my brain whatever they want.
Solution: I'd like to noscript out a utility do do the following:
Read input from the user to specify the known good hash.
One of the following:
Have the user specify the hashing algorithm to use (md5, sha, sha256, etc) via command line flags OR, if I get especially froggy, I'd love to learn how to make a live selection menu.
Use regex matching to recognize the kind of hashing algorithm based on the hash input. This is a blind assumption currently as I haven't looked at all the mechanisms and their outputs yet.
Read input from a CLI argument specifying the file we're trying to verify.
Run the appropriate hashing mechanism against the file and store the hash portion of the output. (Using the preexisting commands in Linux/MacOS like sha(x)sum, md5sum, etc)
Compare the known value against the generated value and return a happy little message.
Provide a command line help option with a print of the available options and command usage.
Now, this is a learning project for me. I'm in the market to learn bash (Better, I'm a hopeless novice currently) or python (Even more of a novice). I'm not sure which approach is more appropriate for the stated goals. From what I can tell, both can perform all of the requirements without blinking an eye.
While researching for this post I did find that my suspicion is correct and the target OSs (linux and macos) use different commands for the goals, so I guess it'll also need to determine the current OS as well.
https://redd.it/xxcy90
@r_bash
Hi Everybody! (Hi Dr. Nick!)
What I like about this subreddit is that while it's bash focused, it's not generally populated with bash zealots or bash absolutists. What I've seen over a number of posts is more of an approach of "Right tool for the right job". So with that in mind I want to explain my problem/desired outcome and get your opinions on what the right tool is for this.
Problem: (Better) Websites will provide you with the file hash for the file you're downloading so you can verify authenticity/integrity when you have it on your system. My eyes are lazy. When I'm verifying a hash I simply make sure the last 6 or so characters match between the two files. My eyes are also assholes and like to tell my brain whatever they want.
Solution: I'd like to noscript out a utility do do the following:
Read input from the user to specify the known good hash.
One of the following:
Have the user specify the hashing algorithm to use (md5, sha, sha256, etc) via command line flags OR, if I get especially froggy, I'd love to learn how to make a live selection menu.
Use regex matching to recognize the kind of hashing algorithm based on the hash input. This is a blind assumption currently as I haven't looked at all the mechanisms and their outputs yet.
Read input from a CLI argument specifying the file we're trying to verify.
Run the appropriate hashing mechanism against the file and store the hash portion of the output. (Using the preexisting commands in Linux/MacOS like sha(x)sum, md5sum, etc)
Compare the known value against the generated value and return a happy little message.
Provide a command line help option with a print of the available options and command usage.
Now, this is a learning project for me. I'm in the market to learn bash (Better, I'm a hopeless novice currently) or python (Even more of a novice). I'm not sure which approach is more appropriate for the stated goals. From what I can tell, both can perform all of the requirements without blinking an eye.
While researching for this post I did find that my suspicion is correct and the target OSs (linux and macos) use different commands for the goals, so I guess it'll also need to determine the current OS as well.
https://redd.it/xxcy90
@r_bash
reddit
Opinions on the right tool
Hi Everybody! (Hi Dr. Nick!) What I like about this subreddit is that while it's bash focused, it's not generally populated with bash zealots or...
using acpi with fahrenheit printout
The temperature readouts via tooltips in the taskbar for icewm are in celsius. For me, this is inconsistent with my conky configuration and could lead to confusion on my part. The \~/.icewm/preferences file does not seem to provide a way to set temp defaults to fahrenheit. The naming conventions for the variable names in preferences seems to imply that acpi is being used in the background. Acpi has a -f flag that enables printout in fahrenheit. Nowhere does man indicate that there is a config file for acpi. Any ideas? Using ubuntu 20.04. This question is about the executable command at /usr/bin/acpi, not the kernel mod.
https://redd.it/xxix59
@r_bash
The temperature readouts via tooltips in the taskbar for icewm are in celsius. For me, this is inconsistent with my conky configuration and could lead to confusion on my part. The \~/.icewm/preferences file does not seem to provide a way to set temp defaults to fahrenheit. The naming conventions for the variable names in preferences seems to imply that acpi is being used in the background. Acpi has a -f flag that enables printout in fahrenheit. Nowhere does man indicate that there is a config file for acpi. Any ideas? Using ubuntu 20.04. This question is about the executable command at /usr/bin/acpi, not the kernel mod.
https://redd.it/xxix59
@r_bash
reddit
using acpi with fahrenheit printout
The temperature readouts via tooltips in the taskbar for icewm are in celsius. For me, this is inconsistent with my conky configuration and ...
Updating BASH Script
Hello,
I have a bash noscript that another user created that I am having issues performing how I want. I want the noscript to create an nfo file for every episode name in all sub folders. I want to put the noscript in the main folder and run it, and I want it to generate the files for all the files in every sub folder of the main folder. Below is the noscript and when it runs, it just creates 1 .nfo file with the names of all episodes in that one, and that does not work. Any help is greatly appreciated, and I want to thank anyone who can help in advance. The code is below.
​
#!/bin/sh
# Un-comment the following line to have the shell print the data it's working with
#set -x
cd "/Users/user1/Downloads/show/"
filelist="files.lst"
collectfiles() {
# Recursively search the directory noted by the first argument, or the current working directory if not
# provided that matches the regular expression matching the various file extensions we care about,
# and print the results to the file specified by the second argument, or the value of the variable $filelist
# if not specified.
(find "${1:-.}" -maxdepth 2 -type f -iname '*.(mkv|avi|mp4|mov|wav|mpeg|mpg)' -print > "${2:-${filelist}}")
}
generatexml() {
# Collect all the files of interest using the function `collectfiles
generatexml >> "${outputfile}"
# Close the episode list
printf '%s\n' '</episodedetails>' >> "${outputfile}"
}
main "${@}"
https://redd.it/xxqjfc
@r_bash
Hello,
I have a bash noscript that another user created that I am having issues performing how I want. I want the noscript to create an nfo file for every episode name in all sub folders. I want to put the noscript in the main folder and run it, and I want it to generate the files for all the files in every sub folder of the main folder. Below is the noscript and when it runs, it just creates 1 .nfo file with the names of all episodes in that one, and that does not work. Any help is greatly appreciated, and I want to thank anyone who can help in advance. The code is below.
​
#!/bin/sh
# Un-comment the following line to have the shell print the data it's working with
#set -x
cd "/Users/user1/Downloads/show/"
filelist="files.lst"
collectfiles() {
# Recursively search the directory noted by the first argument, or the current working directory if not
# provided that matches the regular expression matching the various file extensions we care about,
# and print the results to the file specified by the second argument, or the value of the variable $filelist
# if not specified.
(find "${1:-.}" -maxdepth 2 -type f -iname '*.(mkv|avi|mp4|mov|wav|mpeg|mpg)' -print > "${2:-${filelist}}")
}
generatexml() {
# Collect all the files of interest using the function `collectfiles
telling it where to search
# as well as where to record the results
collect_files "${search_directory:-${PWD}}" "${file_list}"
# Verify there are results and they can be read
if [ -s "${file_list}" ] && [ -r "${file_list}" ]
then
# Set the shell to operate on text a full line at a time
OLD_IFS="${IFS}"
IFS='\n'
# Read a line out of the file and store the value in the variable $filename
while read -r filename
do
# Reset the shell to operate on text normally
IFS="${OLD_IFS}"
# Strip all text leading to and including the first '-' character from the variable $filename
# storing the result in the variable $file_noscript
file_noscript="${filename##*-}"
# Remove the file extension from the variable $file_noscript
file_noscript="${file_noscript%.*}"
printf '<noscript>%s</noscript>\n' "${file_noscript}"
# Ensure the next loop iteration gets a full line of text
IFS='\n'
done < "${file_list}"
# Ensure the shell's configured to operate on text normally again
IFS="${OLD_IFS}"
fi
}
main() {
# Look at man 1 getopts or man bash to see how you can add argument handling
# to specify where to look for files instead of having to remember which order the arguments go in
# Allow the user to specify the output filename
output_file="${2:-dpna.nfo}"
# Allow for searching a specific directory
search_directory="${1:-.}"
# Create the XML header
printf '%s\n' \
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' \
'<episodedetails>' > "${output_file}"
# Use the generatexml` function to produce all the noscripts and fill in that portion of the filegeneratexml >> "${outputfile}"
# Close the episode list
printf '%s\n' '</episodedetails>' >> "${outputfile}"
}
main "${@}"
https://redd.it/xxqjfc
@r_bash
reddit
Updating BASH Script
Hello, I have a bash noscript that another user created that I am having issues performing how I want. I want the noscript to create an nfo file...
how to set a variable as a functions name
hi.
i am using a for loop to make functions from code stored in there own files.
but that wont work, becouse you for some reason cant use a variable to set a function's name... how could i do this? or what are alternatives? alias won't work for me, as you cant use aliases in a shellnoscript.
https://redd.it/xxuzve
@r_bash
hi.
i am using a for loop to make functions from code stored in there own files.
if [ ! -x "$DATA/internal/$cmd" ] then chmod +x "$DATA/internal/$cmd" ; fifunction $cmd { $DATA/internal/$cmd } donebut that wont work, becouse you for some reason cant use a variable to set a function's name... how could i do this? or what are alternatives? alias won't work for me, as you cant use aliases in a shellnoscript.
https://redd.it/xxuzve
@r_bash
reddit
how to set a variable as a functions name
hi. i am using a for loop to make functions from code stored in there own files. `if [ ! -x "$DATA/internal/$cmd" ]` `then chmod +x...
MKVpropedit all files in directory
I'm trying to create a bash noscript to bulk change the color metadata of all files in a folder.
The command is
The noscript I usually use for loops is giving the error "Error: More than one file name has been given ('a.mkv' and 'b.mkv')
How do I write the noscript to execute all files?
https://redd.it/xy4i6z
@r_bash
I'm trying to create a bash noscript to bulk change the color metadata of all files in a folder.
The command is
mkvpropedit [FILE] --edit track:v1 --set colour-transfer-characteristics=0The noscript I usually use for loops is giving the error "Error: More than one file name has been given ('a.mkv' and 'b.mkv')
for file in *; do mkvpropedit *.mkv --edit track:v1 --set colour-transfer-characteristics=0How do I write the noscript to execute all files?
https://redd.it/xy4i6z
@r_bash
reddit
MKVpropedit all files in directory
I'm trying to create a bash noscript to bulk change the color metadata of all files in a folder. The command is `mkvpropedit [FILE] --edit...
Needing Help with a Creating a Bash Script
Hello guys, I am completely new to this thing and I have no idea what I am doing. I study graphical design and photography in uni and we have one mandatory course in basic programming. This is the homework we got - could any of you please give me some tips and tricks on how to doit and not fail this assignment?
The assignment:
Each numbered task must be one line in the noscript; commands have to be executed in the same order.The noscript should do the following:
1. Creates a folder "hw1".
2. Downloads "https://.names" and saves it as "names".
3. Sorts the "names" file in reversed alphabetical order and saves it as a file "sorted" that is located in "hw1" folder.
4. Renames the file "names" to "used" and copies "used" to "hw1" folder as "usedcopy".
5. Gets the line with "Model name" of the CPU from lscpu and adds it to "sorted".
6. Creates a new file "foundit" in the folder "hw1". Only if the file is created successfully, it searches in "sorted" for lines containing the letter "m" in case insensitive manner, takes the last one and appends it to "foundit".
7. Removes file "used".
8. Creates ZIP file named [your shool username\]-hw1.zip, which includes the folder "hw1" with all files moved into it.
The noscript must work when somebody else runs it, so do not use absolute paths. Use quotations. Do not use any "if", "else", "for", etc. Do not use cd, sed or awk.
https://redd.it/xyqrjh
@r_bash
Hello guys, I am completely new to this thing and I have no idea what I am doing. I study graphical design and photography in uni and we have one mandatory course in basic programming. This is the homework we got - could any of you please give me some tips and tricks on how to doit and not fail this assignment?
The assignment:
Each numbered task must be one line in the noscript; commands have to be executed in the same order.The noscript should do the following:
1. Creates a folder "hw1".
2. Downloads "https://.names" and saves it as "names".
3. Sorts the "names" file in reversed alphabetical order and saves it as a file "sorted" that is located in "hw1" folder.
4. Renames the file "names" to "used" and copies "used" to "hw1" folder as "usedcopy".
5. Gets the line with "Model name" of the CPU from lscpu and adds it to "sorted".
6. Creates a new file "foundit" in the folder "hw1". Only if the file is created successfully, it searches in "sorted" for lines containing the letter "m" in case insensitive manner, takes the last one and appends it to "foundit".
7. Removes file "used".
8. Creates ZIP file named [your shool username\]-hw1.zip, which includes the folder "hw1" with all files moved into it.
The noscript must work when somebody else runs it, so do not use absolute paths. Use quotations. Do not use any "if", "else", "for", etc. Do not use cd, sed or awk.
https://redd.it/xyqrjh
@r_bash
Issues with needrestart when installing packages
Hi,
I was building a bash installer that should work on RHEL and Debian based distros. It's adding a new repository, installing a few dependencies and then installing the actual software itself.Output from
I thought everything was fine, until users started reported that the noscript would hang forever when installing the dependencies. It was not possible to Ctrl+C so you had to kill the installation process.
Turns out that
So, is there any way that I can redirect output from my
I was just redirecting like this:
It's my first attempt at a bash installer and my knowledge of bash is quite limited.
Thanks in advance!
https://redd.it/xyueab
@r_bash
Hi,
I was building a bash installer that should work on RHEL and Debian based distros. It's adding a new repository, installing a few dependencies and then installing the actual software itself.Output from
apt-get -y install was redirected to a log file to keep the console output clean. The noscript would check if apt-get exited correctly.I thought everything was fine, until users started reported that the noscript would hang forever when installing the dependencies. It was not possible to Ctrl+C so you had to kill the installation process.
Turns out that
needrestart was the cause of this. On some systems, needrestart would open a dialog and wait for user input - the output from this had been redirected to the logfile, however.So, is there any way that I can redirect output from my
apt-get -y install command to a file without needrestart breaking my noscript?I was just redirecting like this:
apt-get -y install dependency1 dependency2 dependency3 > install-dependencies.log.It's my first attempt at a bash installer and my knowledge of bash is quite limited.
Thanks in advance!
https://redd.it/xyueab
@r_bash
reddit
Issues with needrestart when installing packages
Hi, I was building a bash installer that should work on RHEL and Debian based distros. It's adding a new repository, installing a few...
Does anyone know how to create a program that hat accepts three parameters and displays their average? Thanks :)
https://redd.it/xytxhx
@r_bash
https://redd.it/xytxhx
@r_bash
reddit
Does anyone know how to create a program that hat accepts three...
Posted in r/bash by u/Hercules_GB • 0 points and 3 comments
While read do if
I have this one liner im trying to solve. It checks a file and does some task whenever the file changes.
Now i need to extend it a bit so that it checks another file to see if a specific keyword exist.
inotifywait -m -e close_write "/tmp/test.txt" --format --quiet | while read -r dir; do if [[ grep -q "Pattern123" "/tmp/test123.txt" \]\]; [ $? -eq 0 \] && echo "Pattern Found!" || echo "Pattern nonexitent" done.
I do belive the do if statement is the error here.
Help is appreciated how i can solve this in one line.
https://redd.it/xz0687
@r_bash
I have this one liner im trying to solve. It checks a file and does some task whenever the file changes.
Now i need to extend it a bit so that it checks another file to see if a specific keyword exist.
inotifywait -m -e close_write "/tmp/test.txt" --format --quiet | while read -r dir; do if [[ grep -q "Pattern123" "/tmp/test123.txt" \]\]; [ $? -eq 0 \] && echo "Pattern Found!" || echo "Pattern nonexitent" done.
I do belive the do if statement is the error here.
Help is appreciated how i can solve this in one line.
https://redd.it/xz0687
@r_bash
reddit
While read do if
I have this one liner im trying to solve. It checks a file and does some task whenever the file changes. Now i need to extend it a bit so that it...
Replace all occurrences of a persons name
I have a text file with names (temp_filteredlist.txt) and a file with facts about several persons (temp_facts.txt).
I have used a for loop to create several files for each person in the list, and used grep to get the name and fact about that person into a file with their name.
names=$(cat temp_filteredlist.txt)
for name in $names;
do
touch facts-$name.txt;
grep -i "$name" temp_filteredlist.txt > facts-$name.txt
grep -i "$name" temp_facts.txt >> facts-$name.txt
wc -l facts-$name.txt >> facts-$name.txt
done
I have also tried to get the number of facts about that person on the last line, but I get the number of all the lines, not only the facts + I get the file name besides the word count. So I need some input on how to fix that.
Now it looks like this:
andrea
When it rains, Andrea goes running for at least 2 hours.
Andrea thinks that the winter is better than the summer.
Kyle will visit Andrea in the countyside tomorrow.
4 facts-andrea.txt
But I want the structure to look like this for all the files:
andrea
When it rains, Andrea goes running for at least 2 hours.
Andrea thinks that the winter is better than the summer.
Kyle will visit Andrea in the countyside tomorrow.
4
The “main” task I’m trying to solve now, is to replace all occurrences of that persons name with “this funny person” and replace all occurrences of numbers (not digits) with my birthday.
At the moment I have tried this:
sed -E 's/andrea/THIS FUNNY PERSON/ig; s/[0-9]+/30.DES/g' facts-andrea.txt >> facts-andrea.txt
sed -E 's/daniel/THIS FUNNY PERSON/ig; s/[0-9]+/30.DES/g' facts-daniel.txt >> facts-daniel.txt
But this is not a “universal” way, because I have to write each name and file name, and I’m not sure how to solve this. I tried a for loop, but it didn’t work (I probably wrote something wrong).
Also the way I currently have written it, doesn’t quite work either because the output is this:
andrea
When it rains, Andrea goes running for at least 2 hours.
Andrea thinks that the winter is better than the summer.
Kyle will visit Andrea in the countyside tomorrow.
4 facts-andrea.txt
THIS FUNNY PERSON
When it rains, THIS FUNNY PERSON goes running for at least 30.DES hours.
THIS FUNNY PERSON thinks that the winter is better than the summer.
Kyle will visit THIS FUNNY PERSON in the countyside tomorrow.
30.DES facts-THIS FUNNY PERSON.txt
I get the output 2 times and it replaces digits when I only want it to replace numbers.
If I change the >> to > I get a empty file..
https://redd.it/xz2sck
@r_bash
I have a text file with names (temp_filteredlist.txt) and a file with facts about several persons (temp_facts.txt).
I have used a for loop to create several files for each person in the list, and used grep to get the name and fact about that person into a file with their name.
names=$(cat temp_filteredlist.txt)
for name in $names;
do
touch facts-$name.txt;
grep -i "$name" temp_filteredlist.txt > facts-$name.txt
grep -i "$name" temp_facts.txt >> facts-$name.txt
wc -l facts-$name.txt >> facts-$name.txt
done
I have also tried to get the number of facts about that person on the last line, but I get the number of all the lines, not only the facts + I get the file name besides the word count. So I need some input on how to fix that.
Now it looks like this:
andrea
When it rains, Andrea goes running for at least 2 hours.
Andrea thinks that the winter is better than the summer.
Kyle will visit Andrea in the countyside tomorrow.
4 facts-andrea.txt
But I want the structure to look like this for all the files:
andrea
When it rains, Andrea goes running for at least 2 hours.
Andrea thinks that the winter is better than the summer.
Kyle will visit Andrea in the countyside tomorrow.
4
The “main” task I’m trying to solve now, is to replace all occurrences of that persons name with “this funny person” and replace all occurrences of numbers (not digits) with my birthday.
At the moment I have tried this:
sed -E 's/andrea/THIS FUNNY PERSON/ig; s/[0-9]+/30.DES/g' facts-andrea.txt >> facts-andrea.txt
sed -E 's/daniel/THIS FUNNY PERSON/ig; s/[0-9]+/30.DES/g' facts-daniel.txt >> facts-daniel.txt
But this is not a “universal” way, because I have to write each name and file name, and I’m not sure how to solve this. I tried a for loop, but it didn’t work (I probably wrote something wrong).
Also the way I currently have written it, doesn’t quite work either because the output is this:
andrea
When it rains, Andrea goes running for at least 2 hours.
Andrea thinks that the winter is better than the summer.
Kyle will visit Andrea in the countyside tomorrow.
4 facts-andrea.txt
THIS FUNNY PERSON
When it rains, THIS FUNNY PERSON goes running for at least 30.DES hours.
THIS FUNNY PERSON thinks that the winter is better than the summer.
Kyle will visit THIS FUNNY PERSON in the countyside tomorrow.
30.DES facts-THIS FUNNY PERSON.txt
I get the output 2 times and it replaces digits when I only want it to replace numbers.
If I change the >> to > I get a empty file..
https://redd.it/xz2sck
@r_bash
reddit
Replace all occurrences of a persons name
I have a text file with names (temp_filteredlist.txt) and a file with facts about several persons (temp_facts.txt). I have used a for loop to...
How to backup/sync files from multiple remote Ubuntu instances
Hi, not very familiar with file backups on Linux/bash. I have a windows machine and I'd like to backup files from 8 Linux VM's onto the Windows machine (have about 10GB of content per instance). I also have an Ubuntu workstation and can back up there too if easier. Is there software that can backup/sync remote files to my local machine?
https://redd.it/xz1tmu
@r_bash
Hi, not very familiar with file backups on Linux/bash. I have a windows machine and I'd like to backup files from 8 Linux VM's onto the Windows machine (have about 10GB of content per instance). I also have an Ubuntu workstation and can back up there too if easier. Is there software that can backup/sync remote files to my local machine?
https://redd.it/xz1tmu
@r_bash
reddit
How to backup/sync files from multiple remote Ubuntu instances
Hi, not very familiar with file backups on Linux/bash. I have a windows machine and I'd like to backup files from 8 Linux VM's onto the Windows...
What are some good websites with tasks except Codewars to practice using bash?
What are some good websites with tasks except Codewars to practice using bash?
https://redd.it/xz8gpi
@r_bash
What are some good websites with tasks except Codewars to practice using bash?
https://redd.it/xz8gpi
@r_bash
reddit
What are some good websites with tasks except Codewars to practice...
What are some good websites with tasks except Codewars to practice using bash?