Questions tagged [shell]

The term 'shell' refers to a general class of text-based command interpreters most often associated with the Unix & Linux operating systems.

Filter by
Sorted by
Tagged with
1
vote
0answers
11 views

Compressing and encrypting file systems for backups

I am currently backing up remote OS' while preserving the permissions using rsync: rsync -aAX --numeric-ids --delete ... root@X.X.X.X:/ /backup/server/ Now I ...
0
votes
0answers
6 views

Run command with a modified PATH

When I test shell programs for portability, I often want to run them with different implementations of awk, sed, and several other tools. Of course I could make these shell programs flexible by ...
3
votes
0answers
39 views

Systemctl services start and UFW ports allow script

I made a script to start something akin to a "session" in which I start services and open tcp and udp ports in the firewall in order to work with, for example, a full stack project, and stop and close ...
3
votes
1answer
24 views

Check shell programs for portability

There are lots of shell programs that have /bin/sh as interpreter, yet use some features that are specific to bash or other popular shells. I have written a little ...
4
votes
2answers
115 views

A PHP script used on my home server to download YouTube videos

I have a PHP page I used to download YouTube videos, hosted on my Pi 4. The site is only going to be used on my home network (so a dot local address), but it allows me to download videos on my phone ...
6
votes
2answers
937 views

Test to see if installed and if not, install it

Okay all you Linux/shell folks out there. This is my first shell script (2nd if you count "Hello World") and would appreciate some feedback. Basically, I need to test whether ...
2
votes
0answers
40 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 ...
3
votes
1answer
71 views

Compare and Process Common and Uncommon files separately

I have the following files: STUDENT_D19001.T103412_HU.txt STUDENT_D19001.T103412_KU.txt STUDENT_D19002.T113030_HU.txt STUDENT_D19002.T115055_KU.txt STUDENT_D19003.T115055_KU.txt STUDENT_D19004....
5
votes
1answer
257 views

Bash script to check available name in Github

I just wrote this script to check if the name (that has 2 characters: 1 alphabet and 1 number) in Github is available or not so I can accompany this name. Here is my script: ...
5
votes
1answer
42 views

Downsample fastqs

I'm working on a project to downsample some fastqs (files that contain sequences). Each line of the fastq bioinformatics format comprises 4 lines chunks (id, dna sequence, "+", quality score). ...
5
votes
1answer
92 views

Bash script for speedreading training

I have coded a speedreading training bash script. My targed was to make some experience with bash in a funny way. It ...
1
vote
3answers
81 views

Non-recursively replace all uppercase letters in files within current directory with lowercase letters - without looping

Let's say that I have a directory that looks like this: dir | File1.txt | fILE2.md | file3.tex When I execute my bash script from within the dir ...
6
votes
1answer
73 views

Pre-commit hook to prevent large file commits

I've written the below bash script to run as a pre-commit hook. The intention is to check the git staging area for any files larger than 1mb, and prevent the commit if any are present. ...
3
votes
0answers
30 views

NRPE script for monitoring filesystems usage

Next script returns NRPE friendly output. It checks percentage usage of all local filesystems. Desired output if everything is ok: OK | /=56;;;; /boot=20;;;; /opt=40;;;; /var=60;;;; (and ...
3
votes
1answer
29 views

Running a shell command when a file is added to FTP on Linux Ubuntu

I've recently set up a continuous integration pipeline to deploy a .NET Core application to my Linux machine living on the cloud. My CI pipeline publishes my application, (specifically a .NET web ...
2
votes
2answers
119 views

Shell command to output all plugins that exist across multiple wordpress installations

I'm working on a server and need a complete list of plugins that are installed for all wp installations. I only need to know whether a plugin exists or not, it doesn't matter where it exists. For ...
7
votes
3answers
443 views

Inserting command output into multiline string

I'm writing a bash script to that picks up a user password from an environment variable, hashes this, and inserts the results into a postgres database. What I have works and looks fairly readable to ...
3
votes
1answer
54 views

Shell script to set up Ant targets and properties for a new project

I've written this shell script to place Ant build.xml and build.properties into my project directory. It takes two options, one which ensures the project is set up for JUnit test compilation/running. ...
2
votes
3answers
49 views

Write directory new entries to file periodically, keeping the ones that existed in the past

Some backup Bash script on my machine copies a specific directory entries filenames into a text file. Entries that no longer exist have to be kept (entries added during a previous run). The script ...
2
votes
1answer
311 views

Powershell script to stop and start services on demand

The purpose of below code is to stop/start a couple of windows services if they are running/not running, this will be called from a windows command line. The services could be either on a windows ...
6
votes
1answer
82 views

All-core MediaWiki website upgrade script

I wrote the following Bash script to upgrade All-core MediaWiki websites (no added extensions/skins or images - besides logo image). I already tested the essence of this script and it worked for me; ...
1
vote
1answer
49 views

NRPE script for monitoring memory usage

This script based on previous NRPE script for monitoring load average. Same purpouse - get NRPE friendly output with minimal usage of non built in commands. In this case wasn't need to count with ...
7
votes
3answers
246 views

NRPE script for monitoring load average

This script converts a server load value into percentage, compares it with non desired state ($warning and $critical) and returns all information in NRPE (Nagios Remote Plugin Executor) friendly ...
3
votes
2answers
39 views

a wrapper for bbcp

I am writing a small bash wrapper for bbcp. This is a fast network file transfer utility. bbcp requires the destination folder to be the last argument. ...
2
votes
0answers
35 views

Bulk File Rename; Improved Safety and Performance

A function that funnels all filenames into a file and opens that file in vim. The user then changes the names, saves, and quits. Finally the function renames the files in the folder with the new names ...
4
votes
0answers
29 views

Rename files by editing their names in an editor

Inspired by the a recent question to rename files by editing the list of names in an editor, I put together a similar script. Why: if you need to perform some complex renames that are not easy to ...
3
votes
1answer
52 views

Bulk File Rename

A function that funnels all filenames into a file and opens that file in vim. The user then changes the names, saves, and quits. Finally the function renames the files in the folder with the new names ...
1
vote
1answer
43 views

Script to Backup Data to Remote Location. The data to backup depends on the day of the week

I have a script that I wrote, and I'm sure that there is a better way to do it, but can't for the life of me figure it out. Here is the problem statement: I need to backup data to a remote location, ...
5
votes
2answers
39 views

Bookmarking directories

When working on a large codebase, I often need to switch between deeply nested directories quickly. To make my life easier, I came up with a bookmarking script. ...
3
votes
1answer
38 views

Deployment Automatization for docker builds, kubernetes deploys and secret injection

I've written a small script that automates the tasks I previously did manually for deploying onto our kubernetes clusters and I am quite happy with the results I have, but I do think that what my ...
1
vote
1answer
42 views

Remap ls to honor .hidden files

I wrote this code in my .bashrc to remap ls to honor .hidden files. I'm pretty new to shell/bash scripting, so I feel like this is not the most performant way to handle this, and it has some ...
4
votes
2answers
57 views

Command to measure CPU time and RAM usage of process while making sure it does not go over certain ressource limitation

I found some old code of mine and am trying to see if it can be improved. The goal is to write a command that measures a process's CPU time and RAM peak usage and kills the process if it exceeds a ...
2
votes
0answers
42 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 ...
9
votes
2answers
990 views

Count line of code for a JavaScript project

Here is my bash script that I just wrote to count line of code for JavaScript project. It will list number of: Comment lines Blank lines All lines Here is my script: ...
3
votes
2answers
77 views

POSIX shell function for asking questions

I've written a tiny function for asking questions intended for my POSIX shell scripts, where I often need user input. The function takes 2+ arguments, where: Is a string containing the question. , 3....
3
votes
1answer
24 views

Ruby command to edit a field in a SAM file

Inspired by a bioinformatics question on Stack Overflow, I wanted to brush up on my Ruby knowledge, since I’ve been meaning to replace my command-line use of Perl by Ruby. Briefly, the problem ...
4
votes
1answer
68 views

Shell script to calculate the total space consumed by a user by file-size

I'm working with a small bash code which is working fine but i'm just looking if there is better way to formulate this, In this code i'm looking for the Files between year 2002 and 2018 on the 7th ...
4
votes
1answer
86 views

Bash script to setup new Debian installs - follow-up

I have this bash script I've been working on and I have updated it. I was hoping for some advice and/or input on the code. This script is run directly after a fresh install of ...
4
votes
2answers
58 views

Append a note to one of three files based on user choice

The user selects one of the three categories then makes a note on that selection. Then the note is appended and saved to the appropriate list. It took me four hours to write this. I'm trying to learn ...
1
vote
1answer
25 views

Install a Python package based on active_gpu or version [closed]

I have the following code, is there a way to optimize it/reduce the code? ...
1
vote
2answers
43 views

Bash script to find included files in C code

I've got the following shell script (let say get_includes.sh): ...
4
votes
1answer
47 views

Bash function to find contents of a file with a certain extension

I have to read a lot of code and search through many code bases. I frequently find myself using something like grep -r --include=.C "test string" . to find files ...
3
votes
2answers
116 views

bash wrapper around 'git commit' to automatically bump (Python) package CalVer and create matching CalVer tag on new commit

I'm doing a lot of Python development lately for various (small-)data analysis pipelines at work. I've been wrestling with how to robustly and ~automatically version the code at a fine-grained level, ...
3
votes
1answer
139 views

BASH Script to Configure Monitors on Linux via xRandR

My main computer is a laptop which I run i3wm atop Arch Linux. As such, my monitor situation sometimes changes, so I wanted to code a script to configure my monitors based on which ones are connected ...
2
votes
1answer
60 views

Simple bash argument parser

In a bash script, I need to parse arguments that have the following form: The main arguments can be thought of as being a single argument, but I do not want to force users to quote the entire thing, ...
1
vote
1answer
102 views

Detecting the total amount of RAM installed on a hardware from a Linux system using a POSIX shell script

Today, I gave myself a small task of detecting the total amount of RAM installed on a hardware from a Linux system using a POSIX shell script. I ended up using ...
4
votes
1answer
81 views

Shell function to convert .png to .svg file

I needed to convert some custom icons that were in .png format to .svg format and did not want to use an online converter for it. I could not find an out-of-the-box solution online so I created my ...
3
votes
1answer
59 views

Bash program that sets up and configures the environment for new Debian installs

Here is my second version of a bash program I'm writing, as per @hjpotter92 I've updated and cleaned it since last: This script is run directly after a fresh install of Debian, to do: sets up ...
3
votes
2answers
50 views

Check that file is fully downloaded by FTP

I have a task in which I want to handle error occurred in FTP downloading, For which I used the wget command to download a file via FTP and once the download is ...

1
2 3 4 5 6