0
votes
1answer
8 views

running for loop - but wait for string of words in log file to continue

so far I have this: for each in {01..10} ; do ./sb0$each/tomcat_sb0$each start;done that will start my apps at once, but I want it to wait until it reads one line in a file, what's the easiest way ...
0
votes
1answer
10 views

alias can't find a file that actually exists

On my personnal computer, not a server, in my .bash_profile (I'm on OSX) — sym-linked to .bashrc, I have the following line among some others : alias deploy=sh ~/dir/ectory/deploy.sh The file ...
1
vote
1answer
21 views

How do I identify shell script execution vs dot execution

I'm writing a bash script that needs to run on the current process for it to be useful. That is, I want to make sure that the script was invoked with source script.sh or . ./script.sh and not ...
0
votes
0answers
13 views

(MAC) Change location of shell script's shell

When I make an executable shell script ("http://chimpy.wordpress.com/2010/08/29/mac-os-x-shortcut-link-to-python-script/", but without the python part), It's pointer location (The location commands ...
1
vote
1answer
71 views

Using wildcards in scp command

I have a bash script which copies several files to a remote server using scp. This script works fine but now I need to add a file that contains a wildcard in the name and i have a problem with it. ...
0
votes
1answer
39 views

Bash single quotes in find command

I'm having some troubles getting a shell script to work. I'm trying to dynamically generate the find command based on user input and I'm running into the problem that my variables in the find command ...
-1
votes
1answer
96 views

What's needed to have a shell script run via HTTP Post request?

I was wondering what is needed to trigger a shell script with a HTTP post request. Being in my home wifi I want to call http://ip.of.host/req?run and have a script triggered on my host. I guess I have ...
1
vote
2answers
268 views

Shell script bash: Moving file iterate based on month

I have very little knowledge about shell scripts, but unfortunately I have to write one. I want to ask about bash script iteration moving files, I need to move log files sorted by month which will be ...
2
votes
1answer
146 views

Bash script gives “command not found” error on if elif statements

Now before you flag this as a duplicate please understand i did search for this problem and i already tried all of the solutions to no effect. My script: #!/bin/bash echo "Enter the number 3" read ...
3
votes
2answers
212 views

Bash script to run “pecl install oci8”

I am trying to create shell script that will do the initial provisioning of a vagrant vm (running Ubuntu 12.04). Everything (installing php, apache, oracle instantclient, etc,) works fine, except for ...
0
votes
0answers
32 views

Implement Roll-backing in bash script

I have implemented an Ubuntu package in which bash scripts are using. I followed these for making packages in Ubuntu. ...
0
votes
1answer
111 views

What can I do about “cannot execute binary file”

I have a little shell script that simply starts up a Java program. It is installed somewhere deep in the hierarchy, so I don't want to add its containing folder too my path. So I put a symbolic link ...
2
votes
4answers
96 views

Add a display to let user wait in bash

I am looking for a pretty stupid piece of code for bash that will show a kind of "please wait" rolling display, with the characters : - \ | / The first problem is that I don't know the name of this ...
0
votes
5answers
110 views

How to test if a variable is equal to a number in shell

I have this shell script that isn't working. Input: Server_Name=1 if [ $Server_Name=1 ]; then echo Server Name is 1 else echo Server Name is not 1 fi Output: Server Name is 1 But, if i ...
0
votes
1answer
48 views

Is it possible to automatize a shared host setup using bash shell script?

Preamble: Never created a shell bash script before. So, and first of all, I'm not even sure if this IS the right tool for the job. If it isn't, please, and before all, let me know what, in your ...
1
vote
1answer
119 views

Use “>>” Redirection Operator for Non-Existent File In tcsh/csh

I'm writing tcsh scripts and I would like to append to a log file, but if the log file doesn't exist before appending to it, I get an error (reproduced below). In bash the file gets created if it ...
1
vote
1answer
125 views

Bash Script for Rar command

I need a script to rar my files usage will be like this r1 archivename fileordirtocompress with following attributes rar a -m0 -v1024000 -r How whould this bash script look like? #!/bin/bash ...
1
vote
1answer
36 views

Filtering out incomplete log entries

I'm trying to get some garbage collection logs into Splunk. However, when java starts garbage collection, it starts the log entry, then when it's done it puts in the end of the entry. Splunk treats ...
0
votes
2answers
72 views

Instructions embedded in Bash script?

Is there a way to make a bash script require a set of parameters when it's loaded, and if not, it will automatically spit out an echo to the screen giving instructions? Looking at this example of a ...
2
votes
1answer
246 views

Running commands and shell scripts in Ubuntu

I'm trying to run a shell script in Ubuntu to flash my Firefox OS phone. I've downloaded and unzipped the new version. I've launched the shell and navigated to the directory where the .sh file is. ...
7
votes
1answer
1k views

Shell script to find all types of files in a directory with their count

I want to write a shell script or alias to find the number of different types of files in a directory. For example, sample output of script should be: *.h 20 *.c 40 *.cpp 10 Makefile 3
2
votes
2answers
91 views

How can I get the shell-script-mode in Emacs to intepret #PBS -S /bin/bash to be a bash shell code?

I am using Emacs on a LINUX system that uses Portable Batch System (PBS) for controlling the use of resources. The PBS scripts require "#PBS -S /bin/..." as the first line in the script to declare the ...
0
votes
1answer
422 views

How to create Bash script when user root logout sending email alert include history

I found the following command: history | tail -20 | mail -s "log `hostname` pada `date`" mailid[at]corporate.com I want to combine it with an automatic logout script: The system should send an ...
1
vote
1answer
124 views

xargs in shell script

I want to group jpeg images by odd number and even number. So I did like following: $ mkdir odd $ mkdir even $ find . -regextype posix-egrep -regex ".*[13579].jpg$" -print0 | xargs -i -0 mv {} odd/ $ ...
2
votes
1answer
129 views

What this command :(){ :|: & };: does? [duplicate]

What does this shell command do in Linux :(){ :|: & };: How can it be used in Denial of Service attacks?
0
votes
2answers
729 views

Shell Script Error using Cygwin

I got this error after execute shell script as below. $ ./script_test.sh ./script_test.sh: line 3: syntax error near unexpected token `$'do\r'' '/script_test.sh: line 3: `for ((j=0; j<"$N"; j++)) ...
0
votes
2answers
69 views

How do I parse metacharacters for function input in bash?

I wrote a function in bash which gets * as input and therefore sould list all files in that particualar dircectory. but doesn't. Here is what i wrote: # a function that mass deletes files in a ...
1
vote
1answer
196 views

run a shell script on terminal if terminal is idle for few minutes in linux

i can get terminal idle time by w command as follows $ w 14:37:58 up 2 days, 20:16, 2 users, load average: 0.12, 0.16, 0.14 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT ...
1
vote
2answers
169 views

How to merge ls commands colors with the output of find or du?

I have a simple alias to list the size of files&folders in cwd. ( including dotfiles in this case , ignoring zero sizes ) du -sh .[!.]* * | sort -hr | grep -v '^0' which can be achieved ...
1
vote
1answer
122 views

Changing the case of the Nth character of a filename using Bash?

I have a folder of files and I want to change the case of one of their characters at the 5th position. From this: ABC-xyz DEF-xyz GHI-xys To this: ABC-Xyz DEF-Xyz GHI-Xys You'll notice the X ...
0
votes
1answer
836 views

Launching a Shell Script via .desktop in Raspbian Wheezy

I am trying to launch OMXplayer and play a sequence of videos on loop on a RaspberryPi running Raspbian Wheezy. I have got a working shell script which launches and plays the videos courtesy of ...
-2
votes
2answers
282 views

How to run apache server if it not already running

I wonder if it is possible to check whether or not apache2 is running. If it is not running I want to execute it using shellscript Currently I have added a function which I named run_apache which ...
0
votes
0answers
22 views

Loop through folder with higher space usage in shell? [duplicate]

I would like to create an script where give me a report of which folders have the higher usage space and keep doing that until there's no folder anymore. Today I do this manually, with: sudo du -h ...
2
votes
2answers
206 views

Exclude files in a for loop

I want to delete the /lib directory inside apk files. I managed to do this with: for DIR in ~/ABC ~/ABD do cd $DIR for APK in * do if test -f "$APK" then zip -d $APK ...
0
votes
1answer
98 views

how to compare negative floating points in bash

We tested our script and it fails on negative floating points comparison in bash. What are we doing wrong ? $F1=10000000000 $F2=300 FLP=$(bc <<< "scale=5; ($F2 - $F1)/$F2 * 100") if [ $FLP ...
0
votes
0answers
201 views

Rotate Outgoing Ip in Postfix, script not working

I've found what it seems to be a nice piece of code meant to rotate postfix IP but I really can't get it to work. when I run it I get this error: rotate_postfix_ip.sh: 2: Syntax error: "(" unexpected ...
1
vote
2answers
205 views

comparing two directories and getting the output with absolute path

was trying to compare two directories. one directory is the reference directory(dir1) and the other is the directory where modifications(dir2) are being done I need the list of files which are ...
0
votes
1answer
91 views

bash call command on $var value

I am new to shell scripting and stepped through this quick guide: http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html which was helpful but left a lot of questions about working with variables ...
0
votes
1answer
226 views

Combining multiple data files with header while also adding a data column

I have multiple tab delimited data files that are separated by month in the format jan06.txt, feb06.txt, ..., dec07.txt. Within each file, it looks something like: Header1 Header2 Header3 ... Data1 ...
2
votes
1answer
4k 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 ...
6
votes
5answers
4k views

How to echo commands in a bash shell script, but not execute them?

Is there a way for running a shell script with echoing the commands but w/o actually executing them? Let's say I have script removing a file whose name is stored in a variable: #!/bin/bash set -v ...
0
votes
0answers
141 views

rsync shell script

Need some hints on my first shell-script using rsync. I use rsync, because I had some trouble with a graphical Backup that ran twice and now I want this example as shown below to work on two external ...
0
votes
1answer
178 views

Identify text/ASCII files in Linux/Solaris

I have a little project to build a bash script that searches the OS (Linux/Solaris) for the current IP address in files, and replaces them with another IP address. The problem is that IP address ...
0
votes
1answer
215 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 ...
7
votes
1answer
301 views

How to change the appearance of empty folders in finder using Automator?

I'm trying to use Apple Automator to label empty folders in a heirarchy. Basically, I start off a project with a heirarchy of empty folders and fill them as I work. I want a workflow to label all ...
1
vote
1answer
141 views

how to remove “downloading” or 0% complete torrents in rtorrent using bash script?

I have 10K torrents and 7K of them are going too slow. I would like to remove them but the rutorrent and rtorrent interface is unusably slow. I noticed that the info about rtorrent is kept in .session ...
3
votes
1answer
360 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
vote
1answer
98 views

Hard linking directory structure somewhere else

I have one directory where files appear in. I want to run a script regulary that finds all files in that directory that have only one link to them, and hard link them in another directory. However, I ...
1
vote
1answer
61 views

How to put a Number in to a plist with bash

I'm trying to update my com.apple.background.plist. It works but the "ChangeTime" needs to be a Number/Integer in order to work. I tried to place a -int into the code but it gives an error. ...
3
votes
1answer
821 views

When default shell is not bash-compatible, why do bash scripts not work well?

My default shell is fish, because it's a lot nicer. But often when I run scripts, I get errors that seem to be from the bash script being processed by fish. I think this is because the script writer ...