Questions tagged [bash]

BASH is the GNU Bourne Again SHell, the successor to the classic Unix Bourne sh (shell). It's the default shell for various GNU systems.

Filter by
Sorted by
Tagged with
2
votes
1answer
73 views

Tagging the directories and switching between them by tags

MOTIVATION I have this small software package that allow users to maintain a simple text file that looks like tag1 path1 tag2 path2 . . . For example, it may ...
2
votes
1answer
1k views

Chrome extension to get youtube video's URL

I needed something that would get the URL of a chosen video from YouTube and store it in a file. Since I didn't find a way to write/edit an existing file with the URL alone, I had to use a patchwork ...
2
votes
1answer
255 views

Website monitor - if site is down, kill the process, contact admin and restart server

My Python-based web server (Tornado module) is pretty complex and keeps going down (seems like usually in the middle of the night), so here's a bash script that kills the process, restarts and emails ...
2
votes
1answer
65 views

Parsing logs in sed efficiently

I have an application which log file has most lines start with a time/date, followed by a debugging level and the actual log message. Often I want to watch the output live and colors make it a lot ...
2
votes
1answer
71 views

Bash script for reviewing .pdf articles

I wrote a bash script for reviewing scientific articles. It adds a blank page for notes and creates a new landscape file. I'm sure it can be made better code wise. Any suggestions? ...
2
votes
1answer
50 views

Controller web interface security

I'm designing a web interface to a controller for my school's bell. Are there any security flaws in this code? The source code is available here. Front End: ...
2
votes
1answer
47 views

Grep to search for array of location targets

Please review my short 65 lines of code: Is there a way to avoid eval (security)? Is there a better way or place to use ...
2
votes
1answer
892 views

Bash to find all placeholder variables in a file and replace will real variables

I am looking to make a generic config file using variables such as: $PLACEHOLDER_USER Then after moving the file into the correct position I want to replace every instance of *$PLACEHOLDER_VARIABLE* ...
2
votes
1answer
708 views

Bash script to set up an ad hoc wireless network

This script creates an adhoc network using hostapd. I have tested it and seems to work reliably. I am new to linux networking and not sure if this is a recommended way to create an adhoc network this ...
2
votes
1answer
2k views

bash script to organize files and cleanup files

I have been working on a bash script for a while now to organize my movie files. I can do it by hand, but at the time I was taking a bash scripting class and thought I would like to use it to create ...
2
votes
1answer
155 views

Bash script to manage multiple Java Development Kits installations

I'm writing a bash script to manage multiple JDKs, the script is very simple, you have to choose a directory when you store all the jdk's, and the script maintain ...
2
votes
1answer
439 views

Tips on good practice in my bash script that logs in to a website, downloads a PDF, adds it to iBooks and uploads it to dropbox

I am running a scheduled script on my iPhone that logs in to a website, downloads a PDF, adds it to iBooks and uploads it to dropbox. All of this happens only when it has WiFi access. I want to make ...
2
votes
2answers
96 views

Shell script: is it doing what I think it's doing

I've not written many shell scripts and cobbled this together from examples. The 'if' condition should check if this is already running and quite if so. The 'wget' call should trigger the php page and ...
2
votes
0answers
23 views

Bash wrapper for connmanctl with autocompletion

So the idea came from the fact that connmanctl only completes filenames/directories when used non-interactively, whereas when used interactively (executing ...
2
votes
0answers
13 views

bash script to delete files resurrected by Adobe InDesign bug

After a March update, Adobe Indesign will resurrect removed directories it was responsible for creating in the first place, but not any files except for one file called "AdobeFnt.lst". So where once ...
2
votes
0answers
66 views

Qutebrowser Searchengine Script

Qutebrowser uses search engines similar to DuckDuckGo's Bangs to facilitate searching. The config.py file for the browser contains a search engine Python dictionary....
2
votes
0answers
37 views

Vim swap file sweep and recovery

This is the draft contents of a function intended to be run after a system crash in order to quickly review all of the recent vim swap files. They will be loaded up into and displayed in a vim ...
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 ...
2
votes
0answers
35 views

Python Script to look for DNS expiration [closed]

I just wrote a Python script that will take a list of urls and find which ones are about to expire. The program queries a database, gets the websites, sanitizes the list, then loops through the list ...
2
votes
0answers
32 views

Bash script to scp specific, most-recent files from remote server

I'm writing a helper script that I wish to be able to share with my co-workers. We all work using macOS Mojave, but all have their own shell configurations. For example, I actually use ZSH and bash 5....
2
votes
0answers
12 views

Auto re-connecting to a VPN on OS X and pointing Squid accordingly

We need to tunnel certain applications over a VPN at work. Ideally we would use a dedicated firewall/network appliance for this but the only permanent infrastructure we have are Mac Pro's running ...
2
votes
0answers
82 views

Bash bitcoin blockchain explorer

I wrote a little bash script that displays the transaction info in json: ...
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 ...
2
votes
0answers
173 views

BASH script to obfuscate android/meterpreter payloads

I have written a little script that does a pretty good job of obfuscating android/meterpreter payloads. It will generate payloads or used supplied msf payloads while also injecting a custom icon. The ...
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 ...
2
votes
0answers
936 views

Elastic Beanstalk configuration using ebextensions container_commands combining leader_only and test

For our Django app running on AWS Elastic Beanstalk, we use a web-server/worker setup. The same code is deployed to the web-server and worker environments, and environment-specific configuration is ...
2
votes
1answer
127 views

Init.d script for Rails managing a Rails app via Unicorn

This script is to enable the remote management of a Rails app via one script. I pieced it together from various blog posts. I am not to familiar with some of the BASH functionality that is used. It ...
2
votes
0answers
112 views

Read file real time with while loop and trigger action on change

I want to read a file real time with a while loop that is being fed by the stdout of a process (inotifywait). The output could ...
2
votes
0answers
87 views

Copy recently modified files from one directory to another

I am new to bash scripting. Could you please give a review of this code that copies recently modified files from one directory to another in bash? The main commands are in my ...
2
votes
0answers
91 views

Chip-8 Emulator in Zsh

I've spent the last few weeks writing a Chip-8 emulator in zsh. It doesn't run in bash but the syntax is nearly identical. I have it on a GitHub repo here: https://github.com/hcorion/chipzsh a ...
2
votes
0answers
146 views

Log all Google Chrome browser activity

This script documents every website visited and writes the text content of each webpage to its own individual file. It seems to work as intended. Is there anything I could do to improve 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 ...
1
vote
1answer
55 views

Prefix all lines on standard error

Is this the best way to prefix all lines written by a Bash script to standard error? ...
1
vote
2answers
111 views

Excluding a long list of words with grep

This Bash program extracts the 20 first lines of each man page present on a system and uses grep to remove lines matching a list ...
1
vote
2answers
43 views

chmod all .htaccess files under all website dirs under public_html dir

This is my code to chmod all .htaccess files under all website dirs under public_html dir. The reason I use this code is to make sure WordPress plugins won't "...
1
vote
2answers
57 views

BASH correct usage of single/double quotes when writing variables to file

(running Ubuntu 16.04.3) I created small script with tasks I do every time I upgrade/change Ubuntu version. One of the tasks is to write script to file, this is actual written file: ...
1
vote
1answer
34 views

Print values of an array while stripping out some parts of the string

Is there a more efficient way to run this? I am especially interested in a way which perhaps does not require a for loop... ...
1
vote
1answer
1k views

script- loop through files and directories

I have written the script, which unzips a zip file (passed as argument to the bash), loops through directory and files, then perform different actions based on directory or file. It is working fine. ...
1
vote
1answer
79 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
1answer
28 views

Mac Bash: how to combine the open and str subtract to one line code? [closed]

new to bash , I use the following code to open the super folder with a file path. function openUp(){ cd $(echo $1 | sed 's@\(.*\)/.*@\1@' ); open .. } like ...
1
vote
2answers
312 views

Create individual files via Bash with MD5 hashes of all files in a directory recursively

I have an archive of photos stored in a directory tree on my Mac like: ./2016/05/17/photo-312.jpg ./2016/05/19/photo-1234.jpg ./2016/05/19/photo-5678.jpg I want ...
1
vote
2answers
172 views

Simple Linux upgrade script in Bash revision 2

As I will be deploying this script on multiple machines with the very same system Linux Mint 18 with rather same configuration, I would like to be semi-sure I won't screw things up much. This little ...
1
vote
2answers
176 views

Crawling SPOJ through cURL and C++

I am trying to write industry standard code. https://www.quora.com/How-do-I-follow-a-user-on-Spoj-for-solving-problems-Refer-Details Someone gave me this A2A. And I wrote this code for it ...
1
vote
2answers
547 views

optimizing a bash script chain - speed suggestions?

i am testing an application that i wrote and want to test the solution my algorithm produces to a Monte carlo solution. I use the harddisk a lot and i was wondering if there was a solution that uses ...
1
vote
2answers
61 views

Creating a backup of a website directory inside the Web Application Root directory in *nix

In CentOS I have a Web Application Root on which I have a website directory. I would like to make an immediate backup of that website's directory by using the zip ...
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 ...
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 ...
1
vote
1answer
22 views

Revised media ingest script

link to original question: Simple media ingest script As per answers I have refactored my code and would like to get feedback on the current structure. The purpose of this tool is to allow someone ...
1
vote
1answer
46 views

bash script - Create virtualhost on development server (ver 2)

Review compatibility, readability, good code standards, security. This is for development server, where webmaster uses GUI fo IDE and fine way to create quickly apache2 virtualhost using GUI but ...