A shell script is a script written for the shell, or command line interpreter, of an operating system.

learn more… | top users | synonyms (1)

0
votes
2answers
266 views

curl shell command always returns error status 0 - even when fails on input errors

Example: trying to upload a non existing file - curl -d @no-real-file http://google.com | echo $? - returns 0. How can I make curl fail on input errors?
1
vote
1answer
73 views

what does =~ in linux means used in if condition to compare values

Actually tomcat/conf/catalina.properties file contains line shared.loader=/usr/share/sfit/conf I mean value has some path. so using shell script we are updating shared.loader values in file. And also ...
0
votes
2answers
56 views

I want to find out word which ends with ()…Use grep

I want to find out word which ends with ()...Using the grep command in linux. grep file_name_where_i_want_to_search "*()" some thing like that....but its not working
2
votes
1answer
846 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
0answers
31 views

Start program from shellscript in background then bring back to foreground later

I'm trying to make a shell script that does the following: Start program ~/x While x is running execute some commands, for example: echo "blabla" >> ~/blabla.txt After the execution of those ...
3
votes
1answer
47 views

Greatest number in a column using shell script

I have a file that contains some data in column format, for example: 219m 219m 3.9g 3.9g 4.0g 4.0g 4.1g 4.1g 4.2g 4.2g 4.2g I want to compare the data and find the greatest value of these. Here g ...
2
votes
2answers
3k views

How to create multiple folders and name them by reading lines from text file?

I have a plain text file named Export.txt. It contains a list of geographical places, preceeded by a 3 digit number with leading zeros. Example --START OF FILE-- 001 Aberdeen 002 Bellevue 003 Camas ...
0
votes
0answers
20 views

Scriptable resize (enlargement) of partition inside LV to end of LV?

I'm trying to automate some KVM installs, and I need to fit an existing image onto a newly created LV. The image is partitioned minimally, so I need a way to enlarge the first partition from the ...
1
vote
1answer
32 views

How to get the path of the newest file among the set of files which contains the same ID?

I want to write a script which will take the ID as an input from the user. Based on that input it will search the directories to match a file which contains the given id. Now, the directory has more ...
0
votes
1answer
65 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 ...
0
votes
1answer
172 views

How to replace an exact matching word using gsub

Please see the below script - On this nawk 'NR==FNR { a[$1]=$2 ; next} {for ( i in a) gsub(i,a[i])}1' file.dat 1.txt 1.txt ioiufeioru dfoiduf MO_CIF_INP438 fjkdj MO_CIF_INP dsjhdf BP_LINKED_TETES ...
1
vote
1answer
85 views

Send me email everytime a certain file is accessed from my apache server

I want to have my server send me an email every time someone accesses a PDF file on my webserver. Perhaps: tail -f /var/log/apache.log | grep pdf > ??something?? How would I generate a new ...
0
votes
1answer
1k views

how to shutdown ubuntu server from shell script?

I wrote a simple shell script to shutdown ubuntu server. then created a cron job to execute this script at 23:59 everyday. #!/bin/bash sudo shutdown -h now I got this error message "sudo: no tty ...
3
votes
1answer
916 views

Linux command-line: Fastest way to disable internet (keeping LAN)?

Split question: this other one here is for Windows. Linux: Fastest way to disable internet (keeping LAN) from command line? I think the easiest way to deactivate internet (not LAN) in Linux is ...
0
votes
1answer
205 views

ConEmu - running a script in the startup console

I have a script called todo that echoes a todo list to the terminal. I'd like ConEmu to run this every time it starts (thus, in the starting tab). How do I write a task to make it do that? todo is on ...
-1
votes
1answer
395 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 ...
5
votes
2answers
370 views

Bash: How to list n random number of files (not head or tail)

I have a large directory containing numerous files of similar kind. I have to send few random files for auditing. These files should not be from the top or bottom (eg. not in head or tail). This is ...
2
votes
2answers
1k views

scriptdir=`dirname $0` not working

I am trying to get the directory where my script is in by using: scriptdir=`dirname $0` but this gives me the following error: dirname: invalid option -- 'b' Try `dirname --help' for more ...
1
vote
2answers
28 views

How to interrupt my script?

I use the following script (which I start from at command) as an alarm: #! /bin/sh set -m while true; do paplay /usr/share/sounds/phone.wav done & I want to bind a key to stop this alarm. Please ...
1
vote
3answers
2k 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 ...
3
votes
1answer
2k 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
814 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 ...
1
vote
1answer
426 views

Unable to run shel scrip file, permission denied

I am having shell script file, basically a setup file for installing xilinx tools. The name of the file is xsetup Also i checked its permission after doing this chmod 777 xsetup In fact the ...
0
votes
1answer
200 views

Cron unable to run shell script

I have been trying to get a shell script to run for hours using cron to no avail. I am trying to have the following bash script run every minute #!/bin/bash ...
0
votes
0answers
49 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
80 views

Retrival of read names from fastq file for a particular seq

I have a fastq file.The reads are of length 75bp. This is how a fastq file looks like @ERR030899.2391 HWI-BRUNOP16X_0001:4:1:16426:3738#0/1 ...
-1
votes
2answers
71 views

how to find number of substrings between delimiter? [closed]

I have the string following something(1)^^^something(2)^^^something(3)^^^ ... ^^^something(n) how to find number of something(s) in the string.
1
vote
1answer
272 views

Ubuntu start Node.js server and open Chrome in kiosk mode

I'd like for a computer to immediately start a Node.js application on boot. I'd then like Chrome to open in Kiosk mode, but only after the server has been started. Looking on the Ubuntu Stack ...
0
votes
1answer
209 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
179 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 ...
1
vote
0answers
37 views

Is there any way to see make file with all variables substituted

I have huge long makefile written by some other guy, where all coomands contain variables. In order to decode what this command is doing i have look around what that variable is and its taking too ...
0
votes
1answer
177 views

Eject all disks and dmg's with Automator script in Mac OS X

I have created an Automator Service to eject all disks in Mac OS X. find /dev -name "disk[1-9]" -exec diskutil eject {} \; This works, but I still receive an error message afterwords: "The action ...
1
vote
3answers
58 views

changing order of files

I have a series of files named in alphabetical order (xaa.tif to xdg.tif). I need to reverse the order of the filenames so that the last file is processed first in a script. I would like to rename ...
1
vote
1answer
207 views

How to rename a movie file and also files ins subdirectories (e.g. subtitles) beginning with same prefix

I've several directories with movie files , and also subdirectories with subtitles files with same prefix or starting with same prefix. I want to rename subtitles files with the Directory name it is ...
0
votes
5answers
2k 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 ...
1
vote
1answer
76 views

How do I write a conditional assignment in a Linux script?

I need to create a formula in a Linux shell script. If this was DOS, I'd (probably) be fine, but I've made the change and need to learn....! D1 = a 5-digit number between 40500 and 49500 (this is ...
1
vote
2answers
331 views

Filling up the hard drive until certain amount of space is left?

I'm doing some testing of a product on Apple and Android devices. I'd like a script that will fill up the devices hard drive until 100KB space is left on the drive it's runs against to. Also in linux ...
1
vote
0answers
116 views

Chrome OS sudo startunity app

I am running crouton unity on a Samsung chrome-book. How do i automate a shell script to start unity into a chrome OS app that I can place on the chrome shelf next to the other chrome apps? i want ...
0
votes
1answer
61 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 ...
0
votes
2answers
254 views

Batch file rename script swapping substrings in filename?

I have a group of files named like title_december_word1_word2.png and want to iterate through the directory and swap word1 and word2 within each file. i.e. go from button_december_state_pressed.png ...
-3
votes
1answer
1k views

batch move/cut folders and its content to another folder

I have this batch script that allows me to copy folders and its content from a text file, could someone help me adjust it so it move/cut the folders+content and not just copy? set ...
0
votes
1answer
47 views

Linux flow control exit to terminal on failure

I have a query with flow control. I want to exit the script to terminal when the message is: HOSTNAME NOT ADDED IN /tmp/hosts EXITING, which is a failure message. if grep -o 'abcdefgh01.was.db.dcbc' ...
1
vote
1answer
460 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
157 views

How do I use shellscripts for rails with 'screen'?

I've recently started Ruby on Rails development, and I'm using Vagrant as a VM to contain my Rails project, because Windows is a terrible OS to use for any sort of Ruby development, due to the ...
0
votes
0answers
51 views

Batch Script For Replacing Files

I'm looking for a batch script to read files from a directory and replace them with a zero sized file, if it can detect some special words and then do this, it would be wonderful. For example think ...
1
vote
1answer
227 views

error when using while loop in bash script

I am getting an error 2: [: missing ] when using the following while loop: #!/bin/sh while ["$INPUT_STRING" != "bye"] do echo "please type something (bye quits) " read INPUT_STRING echo "you ...
1
vote
2answers
307 views

Convert Month Number to Month Name

Is there a way to convert month number to name with a script? example: 2013-10-22 will become Oct 22 Thanks. BTW, I don't have the GNU date and my OS is AIX.
1
vote
1answer
317 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
544 views

How can I save some terminal commands as a file and run them?

I am using OpenSuSe 12.3 I want to create a link on my desktop for some specific terminal commands. The background is that I do some backup via rsync and don't want to type the commands every time. ...
1
vote
1answer
343 views

In a Shell scripts, check version of installed package, make a decision based on output

Looking to write a cross distro / cross version shell script that makes sure a forced version of PHP is installed Example: Ubuntu 12.04 has 5.3, Ubuntu 13.10 has 5.5, Debian 7 has 5.4 I need this ...