Tagged Questions

2
votes
2answers
34 views

How do I use BASH to change “A” Train.flac to 'A' Train in a filename?

I've tried every combination of backslash and asterisk and curly brackets, nothing seems to work. I'm using the terminal in OS X and I would really appreciate it if someone could steer me straight.
1
vote
3answers
190 views

When to use Bash and when to use Perl/Python/Ruby?

We are doing all our scripting with Bash so far, but I'm starting to feel a bit silly about it. While we can of course do everything we want with Bash (it's quite powerful), I'm starting to wonder if ...
2
votes
2answers
286 views

Sending commands to parent tmux session from vim

I have a split window setup with vim and Lynx in tmux. I'm trying to build a script so that I can send a custom command to vim which will save the script I'm working on, switch focus to the Lynx pane, ...
2
votes
1answer
34 views

When I use sudo to run a command, aren't the environment variables visible?

$cat test export var=value $source ./test $cat print.sh echo $var $chmod +x print.sh $echo $var value $sudo ./print.sh I get nothing. I was expecting to see value. What is going on?
1
vote
2answers
135 views

Get the user's home when sudo-ing in a script ran by root

In the manpage of sudo I found the -H option, but I don't seem to understand how it works. The manpage says: The -H ( HOME ) option sets the HOME environment variable to the homedir of the ...
0
votes
3answers
63 views

Scripts shell recording playback

I hope this makes sense. I use 'scripts' to make copies of my ssh sessions for various reasons. When I access the logs via less, etc, I see this: Script started on Mon 12 Sep 2011 08:59:14 AM CDT ...
0
votes
2answers
123 views

What is wrong with my Linux installation if my script won't run with the following error messages

Trying to run some .sh scripts in a very cut down Ubuntu installation, but I'm getting messages of the following style: ./my_script: 61: [[: not found ./my_script: 61: ==: not found ./my_script: 61: ...
3
votes
1answer
330 views

Logging into webpage via script

I'm trying to automate the extraction of some information from a website that first requires me to log in. I have done this in the past (years ago) using wget, but that method no longer seems to work ...
4
votes
4answers
755 views

Ruby shell instead of Bash shell in Ubuntu?

It seems to me that Ruby is far more powerful, and you can also do more powerful scripting with it. Are there any open source implementations out there that could replace Bash with Ruby on Ubuntu, so ...
1
vote
5answers
394 views

zipping all files/dirs in a directory except some?

How can I make a zip of all the files and subdirectories in the directory "mydir", except all those files/dirs that begin with a ".*"? The command: zip -r mydir.zip mydir/ will include everything. ...
1
vote
1answer
291 views

ssh'ing to a host and executing a command not working correctly

I have the following command: ssh $USER@$HOST "ls /ops/pkg/ec/`grep "PKRTS" /ops/pkg/ec | awk '{print $1}'`* > /tmp/tmp_file" What the above SHOULD do..is, ssh to the host then execute the ...
1
vote
1answer
149 views

checking which window is active in a Linux script

In a Linux bash script I can do several things with windows using wmctrl but I'm trying to figure out how to determine what the currently active window is.
0
votes
1answer
183 views

How to exclude HTML elements by ID or class using HTTrack or bash script

I need to copy a website, but I want to exclude specific HTML elements by ID or class in all pages (using a bash script). I need this because I don't want ads or some other annoying features of some ...
2
votes
3answers
236 views

I want to execute the commands in a loop at the same time, not one after another

I'd like to write a loop ('for') that will do some action 'X' number of times. But instead of performing the actions sequentially, one after another, I'd like them to execute simultaneously (in ...
1
vote
3answers
287 views

How Do I Parse a String?

I am new to bash, and I am creating a script that loops through the files in a directory and based on part of the filename, does something with the file, so far I have this: #!/bin/bash ...
1
vote
3answers
340 views

How to try to start a service only if it isn't running? (Linux)

I know I have to count how many instances are running: ps x | grep apache2 | wc -l result if it's running: 2, or else: 1 I also know there is a command called test that I could use to perform the ...
0
votes
1answer
142 views

find and mail if changes has occured, unix

The following script runs and finds if any new suid has been changed, and redirects the output to a file. I want to add a mail command in the script, that will send mail to someone@domain.com. If ...
0
votes
3answers
647 views

Bash: overridding ls -la with ls -la | more (basic bash scripting problem)

Pretty new to bash scripting. Trying to over ride the ls -la command to be: ls -la | more (Seems more useful for me). I added this to the end of my .bashrc. 154 # alias 'ls -la'='ls -la | ...
11
votes
6answers
2k views

What is the difference between executing a bash script and sourcing a bash script?

What is the difference between executing a bash script like A and sourcing a bash script like B? A >./myscript B >source myscript
0
votes
6answers
2k views

How to use ssh from shell script without waiting for password?

I can not use public key method. I also don't want to use expect script. I searched this site for solution but everybody is talking about these solutions. Is there any other way like command line ...
0
votes
4answers
82 views

How to make a script to invoke all others scripts matching a pattern

I have a directory with a lot of scripts to generate figures. All the scripts match the pattern fig*-gen.sh I would like to have a bash script (named allfig-gen.sh) to invoke all figure generation ...
3
votes
3answers
3k views

Looping Through Subdirectories and Running a Command in Each

I have a set of repositories sorted into directories based on their VCS (Git, Mercurial, SVN). With Subversion I was able to run svn update * in the parent directory and it would loop through each ...