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

No such file or directory

Running this command on the server: mongorestore -c basic --drop -v --db my_db -u user -p pass dump/basic.bson Works perfectly fine. But when I put this single line in a script (sh) file: Failed: ...
-1
votes
4answers
114 views

With KSH, how to convert “12345” to “1.2.3.4.5?”

With KSH, if I have a string 12345 and I want to it be converted to 1.2.3.4.5, how can I do that? I tried to use cut but it's not straightforward. echo "12345" | cut -c1
1
vote
2answers
133 views

Unable to validate date format in shell script

I am trying to give a user 3 chances to type in correct date format which is mm/dd/yy. If all the 3 times he puts in wrong date format the code will display "Invalid date" and if once out of the 3 ...
0
votes
0answers
54 views

Linux: Delete all but x files?

I have a series of files with different IDs: File_ID1_1 File_ID1_2 File_ID1_3 File_ID1_4 File_ID1_5 File_ID1_6 File_ID2_1 File_ID2_2 File_ID3_1 File_ID3_2 File_ID3_3 For every ID there is a defined ...
1
vote
1answer
157 views

Backup Dropbox files to local hard disk drive

I want to backup all the stuff from by Dropbox folder into an archive once a week. For this I have an Banana Pi with Bananain Linux. Is there a way to download all files from my Dropbox account with ...
0
votes
1answer
300 views

Running command on Android from host

In order to optimize my work, I want to run commands from my host machine terminal. For example: adb shell sh /data/local/tmp/check_freq.sh The above command runs fine, but some of the commands ...
1
vote
1answer
240 views

automatic new mac setup (dotfiles, scripts, etc)

I'm looking for a way to automate the setup of a new macbook I'm about to purchase. I've done through quite a few during the years and it always takes forever to get everything up properly. I don't ...
1
vote
1answer
34 views

Redirect does not output anything into the files

I have the following batch script which executes several processes and is supposed to redirect their outputs into some log files, howeever when the processes finish running the files are empty even ...
1
vote
1answer
226 views

Powershell script to be called by serveral servers to copy log files to remote location

We have several servers that save log files locally and I'm trying to automate logging to a single network location with a name of the parent folder where log files are stored and date modified time ...
0
votes
0answers
60 views

Removing directories using bash script

I have a bash script which I want to delete 5-day-old directories with a name format such as 01-Aug-2015: find /usr/backup/mysql/$date -type d -mtime +5 -exec rm -rf {} \; This is not working for ...
0
votes
2answers
63 views

How can I execute a shell script when someone changes a file through FTP?

I'm running Ubuntu 15.04 Server on a VPS. I'm trying to make it so that my friend can change a configuration file for a game server through FTP, and then when that's done execute a shell script that ...
2
votes
0answers
62 views

Mount USB-Device (Printer) per Script on Ubuntu 14.04 Virtual Box 4.33

We have ubuntu 14.04 with Windows7 on the Virtual Box 4.33 running. As the USB-Printer is mounted at the host or the guest and there seems to be no solution to make it on both available, now my ...
1
vote
1answer
100 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
197 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
34 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
37 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
41 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
45 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
581 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
53 views

Shell script, AppleScript Mac OS X

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
1answer
45 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; c(${arguments[0]}*$constant)...
1
vote
1answer
62 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
72 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
1answer
136 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 "/tmp/...
1
vote
2answers
37 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
36 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
86 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
392 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
38 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> <subTag2&...
0
votes
1answer
360 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
202 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
59 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 ...
1
vote
1answer
212 views

Concat string with variable after a 'grep'

Here is the structure of my file: g-4.n.g.fr 10.147.243.63 g-4.n.g.fr-w1 Here is my script: #! /bin/sh ip=10.147.243.63 worker=$(grep -e $ip $1 | awk '{ print $3; }') echo "[Hostname: ]" echo ...
0
votes
0answers
77 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
vote
2answers
49 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
114 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
62 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
66 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 g-xx....
0
votes
1answer
437 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
1answer
25 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
172 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
26 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
32 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
92 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 username@...
1
vote
1answer
49 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
163 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
70 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
336 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
191 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 ...