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

learn more… | top users | synonyms (1)

1
vote
1answer
27 views

Monitoring Excessive User Home Directory Growth

I am trying to write a script for a school assignment that will check and see if any of the non-administrative user home directories have increased in size by more than 100 MB in a single 20 minute ...
0
votes
1answer
26 views

Cannot unzip with zip command line

I am having difficult unpacking a zip to a specific directory. I am trying to get all contents of subdirectory of the zipped file and not the parent directory. This is parent directory within zip ...
0
votes
1answer
20 views

Unix Scipt Shell: alert on change of specific files

Could any one Help me with the script Im trying to make a script shell that will alerts/email the root if any of those files has been modified and the script has to auto routine , so the script have ...
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
48 views

I want to read a value from a text file and compare it with a number

I am using windows powershell. I want to retrieve a number which is stored in a text file and compare it with some other number using a shell script. If I use $x=$(cat value.txt) it says "command not ...
-1
votes
1answer
20 views

how to run a shell script on git commit

1) i have a shell script which basically contains some(database testing and integrating test code) , but i have to run this shell script when ever there is commit (or any change ) in my git repo the ...
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
20 views

How to find the currently running app from terminal on OS X?

I'm writing a shell script runs in the background and monitors user activity. I'd like to be able to capture current application/document if possible. How can I do that?
21
votes
6answers
51k views

looping through `ls` results in bash shell script

Does any one have a template shell script for doing something with ls for a list of directory names and looping through each one and doing something? I'm planning to do ls -1d */ to get the list of ...
0
votes
1answer
254 views

Control awesome window manager from console

I would like to accomplish the follwing: determine current tag X in awesome window manager sleep for 10 seconds Jump to tag X no matter what the current tag is. I know i can control awesome via ...
2
votes
1answer
2k views

Loops in Bash for creating sequentially numbered folders

How would I write a BASH script that creates directories test0-test63? I'm thinking something along the lines of: for x in range (64) mkdir ./test'x'
0
votes
1answer
54 views

Excute for loop in subfolder

I have this command : for i in $(svn st | grep \! | awk '{print $2}'); do svn delete $i; done I would like to execute it to a subfolder without making a cd command. Is it possible ? Thanks !
2
votes
1answer
21 views

Loop thru tar file and run commands on each file

I have a process of extracting new code to my servers where the code is packaged in a tar file. Each file referenced in the tar is backed up to a specific directory. I'd like to automate this process ...
0
votes
0answers
24 views

Tools to create a 'GitHub' style index page for files/folder on a fileserver?

My workplace doesn't have a document management system. People just throw files on a shared fileserver, where search doesn't really work. Trying to find information/files for a particular project by ...
4
votes
4answers
4k views

grep changing the delimiter

any way we can change the delimiter that uses grep? I think, by default, grep uses \n as the delimiter.
3
votes
2answers
1k views

How to add commands of windows to local shell of XShell 4

XShell is a very powerful tools to ssh remote computers such as Unix/Linux. And it has built some internal commands for you to run within your Windows. Xshell:\> help Internal Commands: new: ...
4
votes
3answers
2k views

linux shell utils: convert a list of hex to list of decimals

How can I convert a file with a lot hex numbers into the decimal? Example: file1 0x59999 0x5acdc 0xffeff I want to start $ cat file1 | util | cat >file2 and get file2 with smth like ...
2
votes
2answers
2k views

awk match whole word

I want to use awk to match whole words from text file. Including words bounded by non alphanumeric characters. For example - string to search for - ABC Source file - HHHABCCCCH HHH ABC ...
0
votes
1answer
383 views

How do I view the OS installation date on Solaris 10?

How can I find out the system installation date on Solaris? Objective is to verify the date and time that the OS was created (OS creation timestamp).
0
votes
1answer
447 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
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 ...
0
votes
2answers
30 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?
0
votes
0answers
139 views

How to write array data into plist using shell script?

I have fetched multiple dictionaries from multiple plist. after i saved them in array . now i have to merge or write this array to new plist. Is der any command to do this ? Please find below code ...
1
vote
1answer
39 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
25 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
3
votes
2answers
365 views

How to search *upwards* for file? (reverse find)

I'd like to search "upwards" for a file in shell script, e.g. check $PWD, then $PWD/.., then $PWD/../.., etc. until hitting the root. Before I go and roll my own, is there some builtin bash/zsh/find ...
1
vote
1answer
70 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. ...
1
vote
2answers
156 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
17 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
39 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
1answer
352 views

Have the at command return the job id of the task just submitted

Is it possible to have the at command return somehow the job id it just submitted when used from within a script? (kind of like $? retrieves the last exit code or $$/$! retrieve the PID of the command ...
0
votes
0answers
15 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 ...
10
votes
5answers
6k views

Log rotation of stdout?

I have a Linux program which can write information to stdout and stderr. I have a shell script which redirects that output to a file in /var/log. (Via >> and 2>&1.) Is there a way to ...
0
votes
1answer
58 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 ...
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 ...
1
vote
1answer
21 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
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 ...
6
votes
4answers
4k views

Run script in OS X 10.6 on network connection. (like /etc/network/if-up.d/)

Is there any way to run a script when a network interface comes up in Mac OS X? I've tried putting a script named ip-up in /etc/ppp but it doesn't seem to fire when I disconnect and reconnect to a ...
3
votes
2answers
196 views

Fastest way to disable internet (keeping LAN) from command line?

I think the easiest way to deactivate internet (not LAN) is to remove the default gateway, so, assuming LAN is 10.0.2.0/24 and gateway is 10.0.2.1 : In Windows: route delete 0.0.0.0 mask ...
1
vote
1answer
51 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
132 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 ...
0
votes
1answer
43 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 ...
2
votes
2answers
90 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
19 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
votes
1answer
95 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
103 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 ...
1
vote
2answers
263 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
5answers
14k views

Edit and compile Unix shell script from Windows without having to boot up Linux install

When I write a shell script and compile it, I generally load Linux/Knoppix (Unix) in my Windows based PC. This is arduous and I am really tired of loading the entire OS each and every time. Is there ...
2
votes
1answer
145 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 ...
1
vote
1answer
99 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 ...