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

learn more… | top users | synonyms (1)

2
votes
1answer
10 views

Trying to create a shell script to move all files with a certain year in their name to a year based directory

Here is the block of code that I have so far. No matter what I do with the find command, I can't seem to get it to function as I want. Trying to move all files with these long year names into their ...
0
votes
0answers
9 views

I want to take tar backup of the directory whose name will be variable

I am trying to write a shell script in which I want to take tar backup of the folders which are formed on daily basis. For example my parent directory name is "log" and under this directory a ...
1
vote
1answer
2k views

Windows 8.1 does not remember credentials of network location

I have a bunch of computers running Windows 8,1 connected by LAN to one central server that runs Server 2012 R2. I have all my scripts stored on the server, so to be able to run them from the other ...
1
vote
1answer
68 views

How to manualy spawn a client in a specific tag in Awesome?

I already have automatic tag assignation for clients using rules, but sometimes I need to spawn a client in a specific tag. For example, I usualy want my browser (dwb) in tag 2 using the following ...
1
vote
1answer
28 views

parsing condensed options to bash

I have something like this: while [[ $# > 0 ]] ; do key="$1" count=0 echo "$1" case "$key" in -r|--rotate) shift rotate $1 shift ...
0
votes
2answers
19 views

Trunc xml file using unix shell script

I need to select particular set of tags which contains a particular value inside the tag. For example, below is the source.XML file <main tag> <subTag1>1298</subTag1> ...
1
vote
0answers
26 views

Can ffmpeg be paused while recording, and then resume?

I want to record an FM radio station that provides an internet stream. I've worked out the command to record this, and I'm happy with the results. However, once in awhile I will start the command and ...
0
votes
1answer
43 views

Double exit in gzexe

I have seen in gzexe (source) they use the following pattern used in a lot of places all over the file: (exit $res); exit $res What purpose does the exit inside the sub-shell? Doesn't seem to do ...
0
votes
0answers
21 views

Shell script, applescript MAC OSX

I'm trying to copy embedded metadata from image files and write to a .txt file, as well as generate MD5 and SHA1 checksums for the same images to be added to the same .txt file. I can run this ...
0
votes
0answers
6 views

Axel usage with script on UBUNTU

I write a shell-script to download files via axel but always I get a 403 FORBIDDDEN error. At the same time I copied the axel command which generated by my script to terminal manually and it works ...
30
votes
11answers
263k views

How to execute .sh file on Windows?

When I am trying to execute a file(name.sh) in the command line by the command ./name.sh , I am getting the error that: "." is not recognized as an internal or external command, operable or ...
0
votes
1answer
23 views

Particular bash bc usage not storing result in variable

Unfortunately this result in a empty variable, and bc command print its result to terminal anyway while trying to attribute to aux aux=&(bc -l <<< "scale = 5; ...
1
vote
1answer
23 views

Remove invalid domain names with Sed

I'm having trouble writing a sed command do the following. I have a file that should only contain "valid" domain names. How I use with sed to remove any line that does not match an expression? The ...
0
votes
1answer
20 views

Replacing text in multiple files-getting duplicate error

I want to loop through all files (2 for this test) in current folder and replace text. The replacement is working but I'm left with newfile1 and newfile2 in file1 and the same in file 2. Where I just ...
2
votes
2answers
4k views

Moving files and renaming when a file exists in destination folder

I used to do this with Hazel. I'd move everything from ~/Downloads/ to ~/Downloads/Archive/Pictures, ~/Downloads/Archive/Documents, ~/Downloads/Archive/Videos etc. based on the file extension, and ...
0
votes
1answer
11 views

Call MATLAB installed on network drive from Cygwin shell script

MATLAB is installed on a network drive, and I want to call it from a shell script. The installed location is \\apps\matlab2014b$\bin\win64\MATLAB.exe in P:\. I am using Cygwin to run the shell ...
1
vote
1answer
42 views

redirection - why it doesn't work this way

I know there are 3 streams attached to a process when it is run namely the input, output and error stream. And redirection execution work from left to right. I intend to execute a command, redirect ...
1
vote
1answer
22 views

How to get notified when a specific file is deleted in Linux?

I'm looking for a way to monitor a file and trigger an event as soon the file was removed. Once it is removed I will replace/copy a new file and start the monitor again. E.g. watch ...
1
vote
2answers
30 views

write script which differs between mac and windows

I'd like to write a script, which differ between mac and windows users, something like this: if (Mac) do this if (Windows) do that This shall be a script, which starts Cmake and builds the ...
0
votes
1answer
17 views

why do i keep getting the same $SHELL even i am on a different shell already

[oracle@SJOAM ~]$ echo $SHELL /bin/bash [oracle@SJOAM ~]$ sh sh-4.1$ echo $SHELL /bin/bash sh-4.1$ csh [oracle@SJOAM ~]$ echo $SHELL /bin/bash Why am i always in bash !? but the prompt are already ...
1
vote
3answers
43 views

add new line after every end of file's contents while merging multiple files

I have written shell script to merge different file's contents I have created directories f1,f2,d1,d2 and files under them , I need to merge all files's contents : comand is (find /home/ah5024331/f1 ...
0
votes
1answer
57 views

Batch converting files using ffmpeg

Can anyone tell me where I'm going wrong doing this. The idea is to find and convert all files in a directory to m4v's. Regardless of the extension. Then once it has been converted, to generate a ...
0
votes
1answer
20 views

String replacement shell script on AIX

I am using AIX, and there is not an -i option available in the version of sed I am using: sed: illegal option -- i Usage: sed [-n] Script [File ...] sed [-n] [-e Script] ... [-f Script_file] ...
0
votes
5answers
42 views

Extract filename from file using shell script

I have a text file which has the following line: /u/tux/abc/spool/frtbla_mcdetc_0000149099_20101126135009990_1.tif I want to extract frtbla_mcdetc_0000149099_20101126135009990_1.tif; the word after ...
0
votes
0answers
16 views

MySQL Workbench - Add Connection from command-line

I'm writing a shell script to auto-provision a development environment for new employees. The OS is Linux Mint 17 (Qiana) and the idea is to run the script and at the end have a fully configured ...
-1
votes
0answers
40 views

shell script finish but doesn't exit

I have 2 shell script a.sh and b.sh which is running under ksh. a.sh does the following action #!/bin/ksh some action check condition and send email if fail or success call b.sh b.sh does the ...
3
votes
1answer
682 views

How can uptime be used to trigger an action?

I want to write shell or perl code which would give me notification after x days. Basically on SUSE Linux server, there is reboot required after 208 days, else the system would freeze. This is known ...
2
votes
1answer
748 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 ...
1
vote
1answer
1k views

How can I check through command-line the computer form(Desktop, notebook or All-in-one)?

For a very specific reason I need to check the computer form factor(Desktop, Notebook or All-in-one) remotelly, using a command through the command-prompt, powershell or vbs(Windows 7/8 systems). ...
1
vote
2answers
28 views

Controlling output in a Linux shell script

When I run a shell script in bash, I push everything to a file as follows: ./script.sh >results.txt Some of the commands in my script output to the terminal, rather than the text file. For example, ...
0
votes
2answers
41 views

Bash - using grep on user-defined strings

Sometimes I would find it very useful to be able to use grep on a string (without the string being in a file). For example: var="Some random string" $var | grep -e "Some" I guess I could use echo ...
0
votes
1answer
27 views

Bash - enable execution only if script is run from a specific directory

I need to write a shell script that can only be executed if it is run from the home directory of the currently signed-in user, and I have no idea how to check that from the script itself. Any help ...
0
votes
3answers
50 views

Script Shell Extract substring

Please, i'd like to extract string just before '.fr'. Here is some lines of my file: g-82.text.text1.fr.worker1 g-xx.yyyyyy.zzzz.fr.worker2 i'd like to extract this text: g-82.text.text1 ...
0
votes
1answer
64 views

Most favorite scripting language used by IT pros [closed]

What is the most favorite scripting languages used by IT pros and why? I see that Javascript is mostly used by developers while legacy VBScript and Powershell for Windows admins and bash/shell for ...
0
votes
0answers
28 views

Script to open multiple gnome-terminal tabs, each running their own command?

I am currently developing a plugin for Minecraft. My setup consists of five terminal tabs, which I have to recreate every time I log in. I need to cd to the particular directory, then run the ...
2
votes
1answer
67 views

How do I record in VLC media player on a schedule?

I have an IP stream coming through VLC media player in Window 7, and I would like to automate the process of opening the stream and start recording at a specified time, and stop VLC and the recording ...
1
vote
1answer
16 views

Empty line appears while merging different file contents in shell script

I have written shell script to merge different file's contents I have created directories f1,f2,d1,d2 and files under them , I need to merge all files's contents : comand is find /home/ah5024331/f1 ...
-2
votes
2answers
3k 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?
0
votes
1answer
19 views

why i can't run binary from /home path

I have a binary "test", I try to run it as follows: root@g-6:~# ./home/test -bash: ./home/test: No such file or directory Have you an idea, please, about the error ? Thank you so much.
1
vote
2answers
377 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 ...
18
votes
7answers
10k 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 ...
4
votes
1answer
3k views

Bash Shell Scripting - How to iterate through directories, and copy and rename files?

I have a directory setup as follows: /hosted/partner1/logo.png /hosted/partner2/logo.png /hosted/partner3/logo.png /hosted/partner4/logo.png /hosted/partner5/logo.png ..etc. I want to write a ...
1
vote
0answers
29 views

Want to send automatic mails from email server, That To addres has to read from email that i received.?

I want to send multiple mail automatically. I will receive mail as FROM: abc@domain1.com TO: 123@domain2.com BODY: mail contains (username@domain3.com) What I want to is take the ...
1
vote
1answer
29 views

Hit enter automatically when running apt-get install <package> prompts a dialog boxes

I'm running command apt-get install -y <package>. It overcomes confirmation like Do you want to continue? [Y/n] But in the process of updating, I got a popup which asks to hit enter in ...
-3
votes
1answer
48 views

Need to create a bash script for ip filter

I have two files with multiple IP address and i want to fine those ip which in not in second file. file one has 1.2.3.4 4.5.6.7 and file two has 117.239.57.130 117.239.58.226 103.248.120.245 ...
0
votes
2answers
48 views

How can I find all files that contain a string and then replace these files with another?

I want to replace all files (foo.php as example) that contain certain string 'bar' with a backup foo.php file, which is located in ./backup/foo.php. How can I do that? I know if I grep -lrI foo . all ...
1
vote
3answers
498 views

Edit xml file using shell script / command

I need to do this using unix script or command There is a xml file in /home/user/app/xmlfiles like <book> <fiction type='a'> <author type=''></author> ...
0
votes
2answers
98 views

Batch Script: Concatenating multiple files in multiple folders into one file

I have about 20 folders and all of them have around 100 csv files each. I want to combine all of them together into one file. How should I do this? I know about copy command to combine files of one ...
2
votes
1answer
57 views

Unable to execute root commands inside an openvpn script

I'm using the openvpn option client-connect to run a script when a client connects. The script works fine when I use simple commands but when I add commands that need root privileges it doesn't work ...
2
votes
1answer
70 views

Append text to first occurrence of a pattern using sed

Say there is a text file as below: Hello world types="" Mario types="Game" What I want to do is find the first occurrence of type="" and append with word "program". I need output as: Hello world ...