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
6 views

A cron job to change file permisssion

when i run chmod 777 to change permission of a file manually it runs. but when i put it in a cron job, it never changes the permission. #!/bin/bash YESTERDAY=`TZ=aaa24 date +%Y-%m-%d` chmod 777 ...
1
vote
2answers
32 views

Alternative to 'ls -A' in Bash

Is there an alternative to ls -A command in native bash functions? Wildcard * isn't the same. I tried hard to find one, but echo * doesn't show hidden files.
2
votes
1answer
23 views

Swap series of filenames conditionally

If have the following problem: I have a series of files that come in pairs (but not always). There is 2400??????_001.jpg and 2400??????_002.jpg. I need to swap the _001 and _002. So I thought I could ...
3
votes
1answer
24 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
1answer
19 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
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 ...
1
vote
0answers
29 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
0answers
23 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 ...
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
24 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 ...
1
vote
1answer
23 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
31 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
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 ...
0
votes
1answer
21 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
2answers
21 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> ...
0
votes
1answer
59 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
5answers
43 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
1answer
44 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
19 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 ...
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
71 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
30 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 ...
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
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
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 ...
1
vote
0answers
30 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 ...
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 ...
-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
101 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
59 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
71 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 ...
0
votes
1answer
63 views

Remove last column values in field seperated file using unix shell script

The files is seperated by | pipe symbol myfile.txt Hello|how|are|you|hope|you|are|doing|fine Lilly|jasmine|rose|sunflower|nightfire|flowers I want to remove columns greater than 3. I want result ...
2
votes
0answers
69 views

udev rule script “xinput --list” differs in terminal versus log

I'm trying to automate a Huion tablet calibration without much success. I have this output from xinput --list in a normal terminal: ⎡ Virtual core pointer id=2 [master ...
1
vote
0answers
14 views

How do I close a window from an application but not quit the application

I'm trying to have a shell script run and then close itself but not quit Terminal all together. Here's what I have: #!/bin/sh while [ "$JOB_NUMBER" = '' ]; do echo -n "++++++++++++++++++++Job ...
1
vote
0answers
30 views

Check for a failed copy with scp

Is it possible in my code to verify if the file is well copied or not ? ssh -t root@$machine -x "sshpass -p 'ubuntu' scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /home/MyFile.txt ...
0
votes
0answers
17 views

Where to put a configuration file with password/acess token on OSX?

Where to put a configuration file with password/acess token on OSX without versioning on a dotfiles public? Example dotfiles: https://github.com/alexandref93/dotfiles ...
0
votes
1answer
49 views

Script shell get id and kill process

Please, i can't find the error in my command. ssh -t root@$machine -x "sshpass -p 'ubuntu' ssh -t root@$address -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/nul -x 'ps -ef | grep ...
0
votes
2answers
57 views

How to merge multiple files into single file in given directories

I want to write a shell script to merge contents of multiple files in a given directories. DIR1 contains sample1.txt sample2.txt sample1.txt contents :---this is sample1 file--- sample2.txt ...
0
votes
1answer
22 views

Zulu time format

I've a script which generates Zulu time zone. How do I change the format in shell /bash script like this ? 20140730000255 -> 2014-07-30 Thank you in advance Regards
1
vote
3answers
539 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> ...
1
vote
2answers
81 views

Is there a folder-specific .bashrc or .bash_profile?

Is it possible to have a bash script (like a .bashrc or .bash_profile, basically) that is executed only upon cd’ing into a specific folder?