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
3answers
208 views

How to escape binary data for inclusion into bash script

I want to create a bash script that reads a "payload" of binary data from an external file and spit out another bash script with this data escaped and encapsulated inside a string variable. Example: ...
0
votes
0answers
35 views

I want to run a script that will disable my touchpad

I want run a script that will disable my touchpad and it will run every minute. 1. My script is: if [ `lsusb | wc -w` == '76' ] then `/usr/bin/xinput set-prop 16 "Device Enabled" 0` else `/usr/bin/...
-1
votes
1answer
50 views

How to use bash script with tmux terminal?

I use tmux with shortcuts provided by the program. How can i use my shell script for performing several options e.g:check if session exists etc.
1
vote
0answers
97 views

Get filename from a wget --content-disposition

Inside of a bash script I am dynamically downloading a file and so I use wget --content-disposition to ensure the file names are correct, but how would I go about retrieving the name of the file wget ...
1
vote
1answer
33 views

An issue renaming logs with MV

I’ve got log files that are created as log.2015-09-28T13-36-29 and I’m trying to change the names of the log files to better suit logrotate. The following command works to display the file I need ...
5
votes
2answers
381 views

How can I excute my bash shell script from any directory?

I have a shell script at /home/joey/hello.sh Now, I want to execute it anywhere like pwd, cut, sort, grep. So, I just type hello.sh although I am in another directory.
0
votes
0answers
25 views

how does ' =~ ' functions in shell scripting?

I want to understand what is the use of =~ regex function? Both the below mention scripts does the same thing so under what condition do we use [[ and ~. 1. x="abc" y="abc" [[ $x =~ $y ]] &&...
1
vote
1answer
238 views

Automate setup of keyboard shortcuts in KDE5

Can the configuration of keybindings in KDE be scripted? I know the shortcuts are probably stored somewhere in ~./config, but the files doesn't appear to be in a stable or easily scriptable format. So ...
0
votes
0answers
13 views

Reloading tab completion in postinst script

I'm distributing a .deb that (among other things) installs a file to /etc/bash_completion.d/example for tab completion. The file gets installed correctly, but the tab completion is not immediately ...
1
vote
1answer
148 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
122 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
138 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
173 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
321 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
271 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
236 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
61 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
66 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
115 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
202 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
620 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
54 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
46 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
76 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
159 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
38 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
37 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
95 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
454 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
39 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
395 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
218 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
60 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
246 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 ...
1
vote
2answers
50 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
118 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
65 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
69 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
531 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
196 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
27 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.