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
2answers
34 views

grep a file and pipe the output to sed and store sed output in a file

Contents of source.txt: gold green white black blue yellow magenta brown tram kilo charlie tango Hi everyone! I need to solve a mystery. I'm trying to run a small script to grep a file source....
0
votes
0answers
12 views

Mount network share point at login - Mac Network

I've recently taken charge of a suite of 25 macs + mac server. The network is a school network with a 150ish users between 4/5 class groups. I've made network folders on a raid drive attached to the ...
0
votes
1answer
26 views

How to write a Bash script that accepts options?

I'm writing a Bash script to make easier to start a local webserver that I use for testing purposes; I don't need it running all the time, it is more useful to me to start it when I need it. Right ...
0
votes
0answers
27 views

command_not_found_handler not allowing cd command

I have the following code block in the ~/.bashrc file function command_not_found_handle { for dir in $@; do path="${path}${dir}/" done if [[ -d ${path} ]]; then echo "...
0
votes
0answers
17 views

Shutdown script not running

I configured a Minecraft server to run at startup inside a screen session. I'm on an EC2 AWS Instance. I would like to stop it at shutdown, so I created the following file inside /etc/init.d /usr/...
0
votes
0answers
27 views

bash script + printf + how to indent the lies with printf

I have many files like the following ( the same concept on all the files ) more list-OS23 linux-d linux-01 fedora-linux-c Solaris_machine1 AIX-65 linux-redhat18 unixware7-h unix-...
1
vote
1answer
21 views

Powershell Script not firing

I'm pretty new to powershell but im executing the following script in PS ISE: $source = "E:\MEX_Websites\Customer_Hosting\MyFolderB\Reports\" $filter = "*.*" $fsw = New-Object System.IO....
0
votes
1answer
506 views

My shell script is giving me the wrong output

I have created a script that is supposed to (in the below section) store the name and location of their corresponding values in an assigned variable, then list the name variables in a column. I have ...
1
vote
1answer
72 views

Bash Scripting and quotation

I'm reading a couple of books on bash scripting, and struggling to understand proper quotation and the use of IFS. Perhaps someone can help me with a small example involving filenames with quotes. ...
0
votes
0answers
40 views

Unable to run python script remotely through SSH on ubuntu 12.04

I am trying to implement a networking model(functioning well on ubuntu 14.04) on my system(ubuntu 12.04), which involves connecting with nodes(machines) remotely and running python script on them. For ...
0
votes
2answers
25 views

Find-replace within hierarchy of XML files

I have around 350 XML files spread throughout the /abc directory. I would like to find all instances where the value of the alt attribute is exactly 'blah blah': <image alt="blah blah" src="../...
0
votes
2answers
66 views

Importing variables in one shell script from another without executing the referred shell script

I have 2 shell scripts, file1.sh and file2.sh file1.sh #!/usr/bin/env bash export var1="/data/share" export var2='password' echo "Hello" file2.sh #!/usr/bin/env bash source file1.sh echo $var1 ...
0
votes
1answer
6 views

(Linux) How to launch instance of an already running application in blocking mode?

For explaining I use Firefox, but it also happens with other applications, here's the script: $ cat ff.sh #!/bin/sh firefox http://superuser.com/ echo "$?" Let's say Firefox is closed, when I run $...
0
votes
1answer
26 views

Prepend file names in shell

I have 100 .png files in a folder say test.png, example.png, etc. I want to prepend them with New_ so that it will be renamed as New_test.png, New_example.png etc. How can I do it in shell.
0
votes
1answer
14 views

Unix, Shell Scripting

I am extracting data from an Oracle database and writing it into a flat file. I need the line delimiter to be FFLF. I am able to add the FF character but I am unable to remove the CR character. How ...
0
votes
0answers
15 views

Run shell command after svn update in PhpStorm and IntelliJ?

We have some scripts that autogenerate helper code files. We occasionally get errors (eg. during reviews) because we forgot to run a script to regenerate the code to reflect recent changes. I'd like ...
2
votes
1answer
66 views

File disappeared after move

I have used the following command hoping to move pdf files from \\netdrive\F1\F2\Source\ to another folder \\netdrive\F3\F4\Des\ Command: PushD "\\netdrive\F1\F2\Source\" &&(forfiles /...
0
votes
1answer
24 views

Add character before a very large file to send to a shell script

I am trying to run a shell script on a 31,65 Go json file. ./oetl.sh database.json I need to have brackets before and after the file. What I have in database.json : {..},{..},.. What I want : ...
-1
votes
1answer
24 views

How to write shell script to mount a sd card into a folder?

I need to write a shell script which should run on startup. In this script my aim is to mount my sdc dev into a folder . Normally if run mount /dev/ /foldername on terminal it will mount How can I ...
1
vote
1answer
23 views

Working with different implementations of cp across different environments

So I figured GNU's cp is different than OSX's (BSD). While OSX copies the contents of a directory that ends with a slash, or the directory itself without the slash, GNU/Linux just treats somedir and ...
1
vote
2answers
44 views

Can i execute a Linux command on shell script?

Can i execute a linux command on my bash shell script. for example how can i execute ifconfig on shell script. when i execute the shell the output of ifconfig should come on terminal. is there any ...
0
votes
1answer
39 views

Scripting with tmux?

Can I script several bash/sh instructions to open and run in separate tmux panes? I have about 5 or so different commands that need to be executed simultaneously or consecutively. I usually type ...
0
votes
0answers
36 views

How to automate putty commands when connection is through serial port?

Two files are there. I want to run trial .txt cmd in serial port connectivity with a hardware.pls suggest how to automate this. I will use these cmds repetititvely. Batch file cmds below sv.batch ...
4
votes
3answers
64 views

How to create linux user with only and only READ permission not EXECUTE and WRITE permission?

I have created user, e.g. ronly, now I want to give them read only access to few directories on other user home like abc/,xyz/,pqr/ so I put this ronly user in others means not created any group for ...
0
votes
0answers
23 views

sed command removes parent closing tag in xml file

Iam using sed command to replace a string with another in an xml file using below given the command. sed "s/one/two/g" /data/common/codeset-mapper.xml > /data/codeset-mapper.xml But the closing ...
0
votes
0answers
12 views

How to write the shell script which check if the file is present on the cluster file system?

Suppose we have pscp on Windows, and remote control to Linux cluster through key key.ppk, the user and host is name@cluster.com. How, by using shell script (in cmd file), check if some file is present ...
0
votes
1answer
23 views

Implementing changes via script

Learning stage of understanding script. I have to make these below change on every new system. So I created these script, unfortunately it isn't working. I want to understand that if the user input ...
0
votes
2answers
20 views

Monitor log live for error. If error = rerun command and restart log monitoring, if not found = keep monitoring forever

A process in a bash script I'm developing often fails quietly (it keeps running with no error code, but it writes the error in its log file). As soon as the error appears in the log file I want the ...
0
votes
3answers
47 views

Combine multiple lines in a file to a single line

I have a file as below.. "Field1"|"Field2"|"Field3"|"ufghjkrtyrtyfgh$" "Field1"|"Field2 continue on line 2 continue on line 3"|"Field3"|"ufghjkrtyrtyfgh$" "Field1"|"Field2"|"Field3"|"...
1
vote
2answers
131 views

Run a Windows application without displaying its GUI

Is there a way to run a Windows application without displaying its GUI window? I have a 3rd party Windows application which does not have any command line parameter or switch to suppress its GUI. I ...
2
votes
1answer
36 views

How to set different shell prompt color for each newly opened terminal

I am using Ubuntu and can manually change the bash shell prompt color to green using export PS1="\e[0;32m[\u@\h \W]\$ \e[m" However, I want the shell prompt color to automatically change whenever I ...
1
vote
1answer
43 views

Matching a randomly generated integer with a specific place value in a string

In bash I want to prompt user for input in a script. Lets say the input is: #!/bin/bash echo "Please enter a number." read NUM # User enters "12345678" How can I use the next command to generate ...
0
votes
1answer
37 views

How to create a specific folder structure inside multiple subfolders

I have a folder structure that looks like this drwxrwxr-x+ 9 root admin 306 May 3 10:19 . drwxrwxrwx 15 root admin 510 May 5 16:14 .. drwxr-xr-x+ 3 root ...
0
votes
1answer
39 views

How to pipe binary stdout to a compressed tls connection?

Not so long ago, I could use : cat somefile.txt | openssl s_client -connect server:port -quiet -comp However, this command doesn’t work, even with-ign_eof: $ cat somefile.bmp | openssl s_client -...
0
votes
1answer
25 views

To create shell script

I want to create a script to check size of all the files present under particular folder, and if size of any file present under a folder cross 500mb it would trigger a mail to me specifying the file ...
1
vote
1answer
44 views

How to pass array to bash shell script?

How do I pass an array as a variable from a first bash shell script to a second script. first.sh #!/bin/bash AR=('foo' 'bar' 'baz' 'bat') sh second.sh "$AR" # foo sh second.sh "${AR[@]}" # foo ...
1
vote
1answer
27 views

Accessing array index variable from bash shell script loop

I want to access the array index variable while looping thru an array in my bash shell script. myscript.sh #!/bin/bash AR=('foo' 'bar' 'baz' 'bat') for i in ${AR[*]}; do echo $i done The result ...
0
votes
1answer
62 views

How to run a shell script from an AppleScript?

I am using a Mac running OSX Yosemite v.10.10.5. When I try to run my shell script from my AppleScript, I get the following error message: Error message at AppleScript Script Editor error "sh: /...
0
votes
1answer
27 views

Shell Save the array element values in the variables

I need to copy the files from one folder to another, here source and destination information are in the text file. File content: res.txt /var/lib/jenkins/jobs/Android\ Gradle\ test\ build/workspace/...
0
votes
1answer
31 views

Bash script to find content of file in a directory and add value

I have a directory with a huge number of files. I want to write a bash script to - Enter that directory Find out which of them are Perl scripts (but none of them have a .pl extension) Add a line at ...
0
votes
2answers
28 views

Evaluate each environment variable and set it back in ubuntu

I'm trying to write a shell script which reads all the environment variables, evaluate them for included env. variable with in them and re-export after evaluvation. Example - I've an environment ...
0
votes
1answer
33 views

How to programatically modify systemd unit files?

I'd like to edit a systemd's unit file from a shell script. I want to change the unit's only ExecStart line. Using systemctl edit looks smart to me, but the command needs an editor set as ...
1
vote
0answers
21 views

Detecting new USB devices with bash?

I'm writing a bash script that needs to detect when a usb storage device is inserted and assign it to a variable that would otherwise, typically look something like: usb=/dev/sdb. I have a few ...
0
votes
1answer
54 views

searching the string with the time in log file using shell script by passing variables

I want to search a string and subtract the time that is found from the current time. When used, the script should show the lines from that time or from the very next log time frame. I'm able to ...
0
votes
0answers
42 views

PowerShell Script is not digitally signed

I am trying to call a Powershell script from another Powershell script. When I try to execute the script, I receive to following error message: After researching the error on Google, I entered the ...
0
votes
3answers
97 views

Shell script Copy file from one directory to another not working

Hi I am trying to automate the android build system through jenkins. Here I am trying to copy the image file from one directory to another directory but always getting " No such file or directory" ...
0
votes
1answer
54 views

Shell Script excuted fail in Linux at command

When I run a Linux "at" command,I find the user's shell script executed fail, for example,I write the following code in my script #!/bin/csh #or #!/bin/bash echo "Now will excute a shell script" ...
0
votes
1answer
56 views

Shutdown a linux computer depending on the battery level

Is there a way to shutdown a linux-based computer when the battery charge drops below a certain level? I have searched through the shutdown and poweroff manuals but found nothing relevant.
0
votes
1answer
32 views

How to run script in same session without exec?

I have below script to set me in my project:- #! /bin/zsh source ~/.zshrc crld #alias for Project base cd Kenneth_Love/survivalguide workon kenneth_tutorial This script works but doesn't drop me ...
0
votes
2answers
370 views

How to POST file contents using cURL?

I want to do an HTTP POST of the contents (as a string) of a local file located at path/to/my-file.txt to a URL endpoint at http://example.com/. For example, I might want to do the following: ...