Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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
5
votes
1answer
249 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
36 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
79 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
73 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
60 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
27 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
114 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
357 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
39 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
79 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
75 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
44 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
231 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
34 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
34 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 ...
3
votes
0answers
25 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
48 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
41 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
38 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
36 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
41 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
54 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
40 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
818 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
65 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
23 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
65 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
77 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
56 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
24 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
33 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
45 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
96 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
121 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
55 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
43 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
60 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
57 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
49 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 ...
4
votes
2answers
210 views

Sleep until specified time

It's sometimes useful to pause until a specified time (but inconvenient to use at or the like), so I wrote a tiny script to wait until a user-specified time point ...
7
votes
2answers
104 views

Bash script to send notifications when low on ram

Backstory Recently, we've changed the PCs at my workplace to un Linux Mint. It works amazing, is blazing fast and the adjustment time was very short. However, I noticed my PC would freeze completely,...
5
votes
1answer
294 views

Git hook to detect existing tag case insensitive

In my company, we use git as VCS, the main server run under linux but all our code is for Windows and we all develop on Windows. The git tag system is case sensitive on linux but is case insensitive ...
5
votes
1answer
151 views

Bash script to setup new Debian installs

This script is run directly after a fresh install of Debian, to do: sets up syntax highlighting in nano, sets up iptables, sets ...
2
votes
1answer
48 views

File generator in shell script

I'm a student, and most of my lab work includes writing programs (usually .cpp) run them, copy the source code and output to a word file and either mail a pdf to the concerned teacher or submit in ...
2
votes
1answer
54 views

User-friendly script for searching through log files

A BASH script that ask users simple questions and greps the syslog archive files (plain-text and gzipped). The script is fully working; I am looking for advices on: Coding style Possible ...
2
votes
1answer
50 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
1answer
50 views

Making a disk usage breakdown

I'm looking for a better way of doing this code I made. I work for tech support and one of the biggest questions I am asked is: "Hey, how did my disk get so full in my VPS?" I am aiming for output ...