0
votes
1answer
14 views

Backing up github [closed]

I have a bunch of github directories and have been using a script with the "cp" command to backup to an external USB drive. I was wondering if I should be backing up directories that I make for ...
0
votes
1answer
53 views

Execute the shell command in subshell or in background?

Actually I mainly work with Ruby, but now I have created a bash script file. From this script file I am displaying the messages on the screen. Here is my scenario. I have used aosd_cat module for ...
1
vote
1answer
34 views

How to recursively create a directory if it does NOT yet exist?

This seems like a general utility and am wondering if anything already exists. I'm trying to place a timestamped logfile in a directory after a script runs, but need to make sure the subdirectory ...
0
votes
1answer
79 views

New process being created while checking with 'if' in bash

ps -ef | while read line; do for i in $line; do if [ $i = 'bash' ]; then echo $line; fi; done; done; unset i; The command runs properly displaying the Bash ...
0
votes
2answers
378 views

Trying to find any home directory that is writable by anyone

I am trying to locate any user home directories and their files that are writable by anyone. I wrote this: find /home -type d -perm -200 | grep . || echo no world-writable directories here ...
-2
votes
1answer
1k views

Calculate % difference and file sizes between two files

We have two zip files and would like to compare them. We're also interested in calculating the percentage difference between them and the file size. Is there a tool that can do this quickly?
2
votes
1answer
5k views

How can I compare a variable to a text string, rather than integer, in an if/else statement?

In the process of writing a shell script, I ran into an issue with the following if/else statement that falls somewhere in the middle of the script: if [ $act -eq "add" ] then read - "add or ...
0
votes
2answers
89 views

For loop with conditions

I have a script that adds user on many server. Since I'm adding on many server(s) I am using for loop. Below are the output when user is successfully added. 0,22529,User added. If the user is not ...
1
vote
3answers
91 views

Find a file in the CWD or any of its parents

I'm trying to create aliases for commands I'm typing a lot. Because I'm working on a big project built on Laravel I need to use the command line tool artisan fairly often. However, I don't often want ...
0
votes
1answer
244 views

Determining if an argument looks like a valid path

I'm writing a bash script that needs to perform some operation on an argument which is a path The path may or may not correspond to an existing file on the user's system, so I'd like to test whether ...
0
votes
1answer
31 views

Environment auto-install

When I work, I often have to switch computers or virtual machines which means that every time I switch, I have to set up my (Linux) environment again. My question is the following : Is there a tool ...
3
votes
1answer
406 views

Script-specific autocomplete in shell

I create a lot of little scripts to help me in my every day life. I would like to provide auto-complete for them, specially that I intend to share them with people. Now, I know I can create ...
-1
votes
2answers
1k views

Execute multiple commands in one line inside unix shellscript

The question is somewhat related to the question asked here, http://stackoverflow.com/questions/5130847/shell-multiple-commands-in-one-line, but the difference is, I need to execute the whole commands ...
0
votes
2answers
2k views

Automounting SD card when inserted in Ubuntu

I am trying to write a BASH script that automounts an SD card once it is inserted in the card reader, then move all pictures to a folder in the HDD and renaming each file to the date and time the ...
6
votes
2answers
1k views

Writing shell scripts that will run on any shell (using multiple shebang lines?)

I've just started getting deeper into shell scripting, and I've always just thrown my script in a file, marked it chmod +x and then done /path/to/script.sh and let whatever interpreter is the default ...
0
votes
1answer
1k views

Advanced merge directory tree with cp in Linux

I need to: Copy all of a tree's folders (with all files, including hidden) under /sourcefolder/* preserving user privileges to /destfolder/ If there is a conflict with a file (a file with the same ...
0
votes
1answer
546 views

My bash script does not find an existing file (into the script's wd) which name I passed as a parameter in a function

I realized a bash script that works on an existing text file located into the same working directory of the script. The script take name of the file to compute through a function parameter. The issue ...
0
votes
1answer
106 views

Bash delete file when variable = x

I'm creating a bash script which reboots the system at each reboot it adds a new line to a text file, I then read the text file before each reboot. Once the variable holding the number of lines ...
4
votes
1answer
343 views

BASH function not escaping control characters

Hey guys I have a function that I'm using to find stuff, but unfortunately anytime I pass it a control character ($intVal or testing : etc) it chokes. I was wondering what the fix was? I can ...
1
vote
1answer
358 views

How to calculate and group the time differences of specified syscalls when running strace

I'm planing to do some web performance testing (to see how much time it's spent for each file), but it could be useful for any application. I exactly know existence and how to use different ...
0
votes
1answer
236 views

How to quote a command between backticks when shell scripting

The command executed in the following script works: #!/bin/bash -xv REM_DIR="/home/jan/rem-dir" SSHOPTS="-C -c arcfour256 -o "\""ServerAliveInterval 15"\" SSHUSER="jan@example.com" CMD="ssh $SSHOPTS ...
6
votes
2answers
65 views

Process files in a folder that haven't previously been processed

I have a series of files in a directory that I need to carry an action out on using a script. Once the action is done, then I want to keep a log that the file has been processed, so that the next ...
0
votes
1answer
269 views

how to extract string from text using shell script

i have the following text A shell script is a (script) written for "the shell", or command line interpreter, of an operating system. The shell is [often] considered a "simple" domain-specific ...
0
votes
2answers
60 views

Has Anyone Made a Program to Manage Scripts (Non-CM)? Recommendations?

I find myself often writing shell scripts in Linux and losing track of them over time. What I would love is a program that stores a copy of the script, along with a descriptive note I write at the ...
0
votes
1answer
204 views

Authenticate connection to remote repository before committing files

All, I have an app (using shell script) that automates the process of committing to svn , generating svn info and emailing it. But every now and then I get the following Authentication realm: < ...
9
votes
3answers
7k views

Passing two arguments to a command using pipes

Usually, we only need to pass one argument: echo abc | cat echo abc | cat some_file - echo abc | cat - some_file Is there a way to pass two arguments? Something like {echo abc , echo xyz} | cat ...
1
vote
1answer
323 views

How to stop printf from printing escape codes in shell script?

When I run a simple shell script with the following code: #!/bin/sh printf "\e[32m Hello World\n" I get \e[32m Hello World as output as opposed to a green Hello World output.
2
votes
2answers
1k views

How do I use the -ne flag for echo in a shell script?

I'm trying to create a shell script to take an argument and use it to name a terminal tab. So if the script's name is tabnm, tabnm "test" should rename the current tab "test" This is my code: ...
0
votes
2answers
195 views

Awk script usage

where should the awk program command file be placed when I am trying to run the awk command inside a shell script? I guess it should be in the same directory, but not sure. Please help.
1
vote
1answer
895 views

Shell script to rename multiple files from their parent folders name

I have a file structure like this: 00000010 000000001.file1 000000001.file2 00000020 00000003.file1 00000003.file2 00000003.file3 ... So there are folders with 8-digit names containing one ...