Bash scripting is making scripts in the Bash shell language.

learn more… | top users | synonyms

3
votes
2answers
114 views

Found a script on my cron.monthly, i am wondering what's it doing?

I am new to bash-programming, sorry if this might be a kind of stupid question. I found a script on my server and i am trying to understand every line: #!/bin/sh # # man-db cron weekly set -e if ! ...
3
votes
1answer
435 views

Parse multiple HTML to text and rename as parent Directory

In a directory there are many folders .html inside, I would like all HTML parsed as new .txt with the name of the parent directory. Example1/ Index.html>Example1.txt Example2/ ...
1
vote
1answer
167 views

Bash script template to copy files to predefined destination folders

I need an interactive bash script template to copy files to predefined destination folders. If possible, when prompted for user input tab completion would be enabled for a predefined source directory. ...
1
vote
1answer
228 views

qsub -hold_jid -afterok loop not starting

I am trying to run a series of jobs submitted to the cluster, one after the other, by suplpying the following .sh script: Annotation_Loop.sh : #!/bin/bash job=`qsub run_IntersectBed_1.sh 0` for i ...
0
votes
3answers
227 views

win-bash won't detect root drives?

I'm using the windows port of bash known as win-bash, and based on what it says about paths: One important difference is the handling of drives: cygwin uses its installation directory as root ...
1
vote
1answer
73 views

Writing a script to tell which users are currently typing? [closed]

I'm working on a lab for a cyber-security class and need to find out when certain users are communicating with each other (through named pipes). The users use: python gameProgram.py And then that ...
1
vote
1answer
493 views

kill process on external script run as a service

I've setup a linux (CentOS) service to run a script that runs in the backgroud (daemon /home/user/testftp.sh &) or in the context of the start and stop service: # Source function library. . ...
2
votes
1answer
105 views

How to get the result from bash auto-completion as a string?

What I'm looking for is not how to add autcompletion in bash for another program, but a way to get the result of what would have happened in bash to a string, basically: autocomplete "/etc/apa" ...
0
votes
1answer
21 views

What's the syntax to open a Tracker window from the command line in Haiku?

I've tried these: Tracker /path Tracker /path/ /path /path/ ...but no dice (the former two open Tracker's preferences window and the latter complain that /path is a directory.) What should I do? ...
-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?
7
votes
1answer
938 views

bash completion for filename patterns or directories

I'm trying to get a bash completion script set up and having some trouble. I would like to set it up so the completions listed are either files matching a particular extension, or directories (which ...
1
vote
1answer
46 views

UNIX Scripting Possibilities

Need a small help to understand if a task can be accomplished using UNIX script. Situation: Symantec Endpoint Encryption when installed on Mac, a manual intervention is required where a technician ...
0
votes
1answer
167 views

Automatically name output of montage based on input files

I have a folder with images separated into channels: IMAGE_A_R.jpg IMAGE_A_G.jpg IMAGE_A_B.jpg IMAGE_A_RGB.jpg IMAGE_A1_R.jpg IMAGE_A1_G.jpg IMAGE_A1_B.jpg IMAGE_A1_RGB.jpg IMAGE_B_R.jpg ...
0
votes
3answers
145 views

output the items that showed up 2 times and more

How can I select the ips that showed up 4 times or more , for example here? the input file is 192.168.1.28 192.168.1.100 192.168.1.31 192.168.101.2 192.168.1.31 192.168.11.02 192.168.1.31 ...
1
vote
3answers
58 views

How do I get multiple scripts prompted with an alias in Cygwin?

I want to run one command, then bring up a second, but modify it first before pressing enter on it. (Cygwin) I usually just type it all out like this: svn up 8.0; ./merge.py 8.0 12345 I also have ...
1
vote
1answer
2k views

Removing files older then 1 month, but leave files created at the 1st day of the month

I'm trying to remove some archive files from a folder on a CentOS fileserver with a cronjob. The requirements: Remove files of the last month The .tgz-file of the first day of the month should be ...
1
vote
3answers
750 views

How to define alias for command which will be available in shell script?

Here is a part of my .bashrc alias my_command="my_command -1 -2 -3" and its my shell script #!/bin/sh my_command blah blah blah It occurs into error ./aa: line 2: my_command: command not found ...
0
votes
2answers
816 views

ZSH: Read command fails within bash function “read:1: -p: no coprocess”

Edit: Seems to work within bash. It appears the problem is related to zsh. If there is a better site to post this issue on let me know. I am writing a simple script that creates a series of ...
2
votes
1answer
235 views

Bash script: “[[: not found”

This is my code: #!/bin/bash if [[ -d ~/viwiki ]]; then cd ~/viwiki else mkdir ~/viwiki cd ~/viwiki fi if ! [[ -d ./log ]]; then mkdir log mkdir log/log mkdir "log/wget" elif ! [[ -d ./log/log ...
1
vote
3answers
3k views

Bash: Find and replace text strings

I figured this would be easy, but I'm overlooking something simple: I have a text file called test. It contains, for example, the string Alfred Hitchcock. I want to replace this with Alfred\ ...
0
votes
1answer
99 views

How can I check the contents of folders for certain files?

How would I go about writing a script to loop through every folder on a hard drive, find any video files, extract them to the root of the hard drive, and then delete everything else?
3
votes
2answers
174 views

Is a subshell executed with a here string?

I'm trying to better organise a bash script as part of a re-write/re-organisation and am wondering what "best practice" is in the following situation: ymd=`echo "${NOEXT}" | egrep -o -m 1 ...
2
votes
1answer
6k 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 ...
8
votes
1answer
339 views

How to make sed omit not matching lines?

In the following example, sed matches lines starting with an a or a c and prints the first character of that line (a or c): $ echo "ag bh ci dj ek fl" | sed 's/\(a\|c\)./\1/' # Matches lines starting ...
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 ...
5
votes
5answers
915 views

Move all sibling folders into one folder

I apologize that this seems like such a dumb question, but I can't afford to screw it up. I have a bunch of folders like so: /users/me/foo/oops1 /users/me/foo/oops2 ...
1
vote
3answers
92 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 ...
1
vote
1answer
198 views

Cygwin browser script error

I use multiple browsers, and I created a bash script that checks to see which browser is open and opens web pages in whatever browser is already open. I use Windows 7, so I run this script using ...
0
votes
2answers
336 views

Root set environment variables

I have a small bash script which downloads a critical file, opens an SFPT connection, puts the file and closes the connection. As you can imagine, my script has some username and password information ...
1
vote
2answers
58 views

Outputting less into a file

while on bash, i tried to delete the 3 last columns of a file using: head -n -3 file > file but the file comes out empty. I can walkaround it but I would like to know what causes that. Thanks a ...
0
votes
1answer
250 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 ...
0
votes
1answer
1k views

Can't edit '/etc/network/interfaces' file through bash script in Ubuntu [duplicate]

Possible Duplicate: sudo permission denied I got need to edit /etc/network/interfaces through bash script, I am doing something like below... sudo echo something > ...
0
votes
1answer
295 views

bash getopts, parsing ranges

What would the best approach be to parse argument value ranges using getopts? As an example: $ script.sh -r2-4,6,8-10 In my script I would then have an array with the values 2, 3, 4, 6, 8, 9 and ...
3
votes
1answer
415 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 ...
3
votes
3answers
68 views

merge pieces of file together

I have a directory tree of files I need to loop through and reformat the lines. can I do this with sed with some combination of find? for each file, I'll need to adjust the text in the file from ...
1
vote
2answers
656 views

Assign values or string to a variable in linux scripting

I am trying to assign the output of the basename command of a file to the variable "filename". paths is a file that contains the path location, e.g /root/home/david/mynote $FILE is = mynote. grep is ...
0
votes
1answer
40 views

Run a specific command from a directory

I have a bash script where I need to run an init utility within a directory with a configuration file defined. I don't think it's possible to explicitly tell the utility to run the file as an ...
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 ...
1
vote
2answers
243 views

Revising a bash script - Invoking a change of prompt color via a temporary file

I am wondering why the following script won't work: #!/bin/bash read -p 'First lets write PROMPT.SH' echo '#!/bin/bash'>prompt.sh echo "export PS1='\e[1;31m\]\u@\h \W\$\e[0m\] '">>prompt.sh ...
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
0answers
84 views

gnome-terminal flag sh

I'm extremely new to linux, so i kinda need some tutoring... been teaching myself some scripting. Most of the stuff I just copy of sites. what baffles me is the little flags that appear in this line: ...
0
votes
1answer
175 views

output redirection not happening completely

I am running the following command on ubuntu 12.04 bash shell: hping3 -S -p 80 -c 30 www.google.com >> outputfile.txt But the problem is that this leaves some lines in the end and doesn't ...
1
vote
3answers
2k views

How could I make a bash script to execute apt-get?

I'm trying to automatize some configurations I have with bash script, I've never done this before so I tried with something easy like a Hello World! and everything works just fine, but then I tried ...
0
votes
3answers
2k views

Run shell script on Linux box from a shortcut/app in Android?

I have an Ubuntu box which runs XBMC, which crashes occasionally. Since I have no keyboard connected,I have to SSH in, kill xinit, then restart it. I was wondering if there's an elegant way of doing ...
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 ...
3
votes
3answers
107 views

Why doesn't this script work?

I've been using this bash script: for i in $(ls); do mv $i a$i; done to prepend all filenames in a folder with the letter a. I'm afraid that at some point I'll accidentally use this script in the ...
0
votes
1answer
574 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 ...
4
votes
1answer
52 views

How to filter output from a command in OS X

I am in need to monitor the the writes from an unknown application to a known directory through creatbyproc.d. I'm going to have to leave this up and running for up to 36 hours which will not be ...