Questions tagged [sh]
sh, aka Bourne Shell, is the Unix Shell, the standard shell since v7 Unix. POSIX has standardized the shell, and portable shell scripts should conform to /bin/sh syntax.
76
questions
2
votes
1answer
96 views
Editing system files in Linux (as root) with GUI and CLI text editors
My intention is to POSIX-ly write one generalized function for running various text editors I use for different purposes through sudoedit, i.e. editing files as ...
2
votes
2answers
42 views
POSIX-ly finding a specific Java process
In this code I find a list all of the running java processes and give the below function a name to look for, it will do its best. But since I find my approach a ...
2
votes
2answers
47 views
How long a PID has been running (taking multiple inputs)
Tonight I tried to write a POSIX shell script which would allow me to check how long a process is running (via it's ID) and be able to handle multiple inputs:
...
2
votes
1answer
78 views
Random password generator sh script
Yesterday, I was bored and decided to write a random password generator. At first it used numerous temporary files, changed that by using arrays.
This was written on OS X and should work on Linux ...
2
votes
2answers
41 views
High CPU utilisation for Logs Manager shell script
I have written a shell script to manage the tcpdump pcap logs and syslog files in my Linux board, so as to maintain the disk usage to maximum of 70%.
The script checks for the disk usage every ...
2
votes
1answer
48 views
*nix, *bsd, etc basic `tput` color setup
My goal with the below piece of POSIX shell code was to address the more platforms the better with shell tput colors. With this code, I now start all of my scripts, ...
2
votes
1answer
86 views
POSIX shell function to “dump” all given arguments
My today's idea was to create a POSIX shell function to dump all given arguments, typical use would be to call it from a fucntion, where you already know some arguments are not well set (empty; not ...
2
votes
1answer
51 views
Commit the working directory to different branch and switch back
The aim of this script is to snapshot the current working directory of a git repository to another branch. Afterwards, it switches back to the original branch and restores the original state, ...
2
votes
0answers
28 views
sh script to open related URL based on possible nicknames
I'm new to sh and I would like to get feedback on how I can improve my code.
The purpose is simple; I want to open the Jenkins JOB related to a service based on its possible aliases. If I map a ...
2
votes
0answers
18 views
Re-interpolating a value from jq back into jq
I have an almost-json document in a file named "versions.json" like this:
...
2
votes
0answers
43 views
Outputting a standalone shell script from arguments
I am solving an exercise. Essentially, it's a shell script that takes in file and/or directory arguments and outputs another (standalone) shell script that outputs these files, including any directory ...
2
votes
0answers
45 views
Code to backup the history file in Linux
How is the logic, efficiency and can it be improved?
This is a snippet from my .bashrc file; I just wrote it and I've tested it and it almost works. This was the ...
2
votes
0answers
63 views
Shell script to manage passwords
To get my feet wet with shell scripting I wrote this "minimal command line
password manager" (aka pwm) taking inspiration from the well known ...
2
votes
0answers
109 views
Script to configure Synaptics touchpad
I have a shell script to configure Synaptics touchpad settings at login.
Background
You configure the touchpad with the synclient command. Its usage is
...
1
vote
2answers
87 views
Editing system files in Linux (as root) with GUI and CLI text editors #2 (final)
This is the second iteration of this question
A note to start with: the first iteration of this question can be found here:
Editing system files in Linux (as root) with GUI and CLI text editors
As ...
1
vote
1answer
91 views
Bash Code to backup the history file in Linux [closed]
How is the logic, efficiency and can it be improved?
This is a snippet from my .bashrc file, I just wrote it.
The code is supposed to do this:
Backup my ...
1
vote
2answers
172 views
Long-term archiving + encrypting shell script
Yesterday, I very quickly, in an hour, wrote the very first version of my long-term archiving + encrypting shell script.
I am aware it may have too many flaws, but none of them really prevent it from ...
1
vote
1answer
266 views
1
vote
1answer
105 views
Shell POSIX OpenSSL file decryption script follow-up #1
This question is the first follow-up of: Shell POSIX OpenSSL file decryption script
Please read it before you continue reading this. Thank you.
I only have one new problem solved and I would like ...
1
vote
1answer
114 views
Sh script to reduce version number in opkg status file
I have written a script to reduce/lower the version number stored in opkg status file using small shell script, This will enable us to force the opkg to install same version of a Debian package again.
...
1
vote
0answers
39 views
sudoedit_enhanced written POSIX-ly (readlink possible problem?)
sudoedit_enhanced written POSIX-ly challenge
While creating sudoedit_enhanced POSIX (apart from ...
1
vote
0answers
41 views
Interactive Linux upgrade script - Follow-up #1
One year ago I asked for a yearly revision of my Interactive Linux upgrade script.
There is nothing new to the conditions, therefore please read the original question before you decide to comment and ...
0
votes
1answer
49 views
Shell POSIX OpenSSL file decryption script follow-up #2
This question is the second follow-up of: Shell POSIX OpenSSL file decryption script
The first follow-up was: Shell POSIX OpenSSL file decryption script follow-up #1
Both of which have proven very ...
0
votes
1answer
33 views
Shell POSIX OpenSSL file decryption script follow-up #3 (final)
From original very simplistic code: Shell POSIX OpenSSL file decryption script
I learned a lot both from the first follow-up review, and the second one as well, many thanks!
I just need one final ...
0
votes
1answer
379 views
POSIX shell script for generating pseudo-random numbers
My today's goal was to further practice POSIX shell scripting.
So, I decided to write the following POSIX shell script for generating pseudo-random numbers.
Any and all reviews would be appreciated.
...
0
votes
0answers
17 views
Attempt on basic input validation and functional programming in a POSIX shell
In spite of all the POSIX shell disadvantages, I am still sticking with it and I love its portability.
Recently, I was searching for a way of code re-use, which turns out to be functional programming ...