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
0answers
3 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
20 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
24 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, ...
-4
votes
0answers
42 views

How to convert a string to decimal values? [on hold]

I would like to convert word (i.e., a string) to decimal ASCII values, separated by dots, in bash. Example word: test123 Expected result: 116.101.115.116.49.50.51 This is what I have tried so ...
0
votes
2answers
33 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
24 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
43 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
51 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 ...
1
vote
1answer
22 views

Batch file merge two text files

I have two text files and I need to merge them like this: text file 1 [][][] [][][] text file 2 ****** ****** ****** output ****** [][][] ****** [][][] ****** I have already looked ...
0
votes
0answers
12 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 ...
1
vote
1answer
42 views

nested if statement, multiple conditions for if statement

I have a situation to write a script where $MacBook and $SERVER are variables. There is a file that is being read to find the server name. And using another file, I can pull the hardware model (if ...
0
votes
1answer
14 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 ...
0
votes
2answers
29 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
18 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
24 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
25 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
44 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
42 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
68 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
45 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
59 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
34 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
55 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
25 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
12 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
30 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
42 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
21 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
217 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
68 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?
1
vote
1answer
58 views

Automated screensaver configuration in command line/shell script

So I'm configuring some Default User Template LaunchAgents to configure a default screensaver for some of my company's most popular fan art. (It's actually been really well received by the team). ...
1
vote
1answer
41 views

How to create a script that launches a random video file from the folder

So, this is a weird problem. But basically, my nephew likes watching cartoons on my computer sometimes. And that worked well. OVer time, his cartoon folder grew up. Here's the problem: he wants to ...
1
vote
1answer
110 views

Shell Script - Loop to make multiples MySQL Query at once

I've tried to handle this problem, ive a little script to conect into a list of host stored in a file. #!/bin/bash num=$(wc -l < ip.txt) while read ip; do mysql --login-path=login -h $ip ...
1
vote
1answer
34 views

tmux - get pwd of another pane in a bash script?

Is there anyway to find out information about the current working directory of any pane from within a tmux session? I'd like to write a bash script that changes the directory of the current pane to ...
1
vote
2answers
125 views

Shell Script User Input Date Validation

How would I go about performing date validation on user input in a shell script? I want to notify the user if they enter the date in the wrong format. The correct format would be YYYYMMDD.
1
vote
1answer
68 views

Bash quotes unescaped on command substitution

Can someone explain me why this is working (listing the contents of a directory that has a whitespace in its name): ret="$(ls "my dir")" Shouldn't it rather be interpreted as: ret="$(ls " my dir ...
0
votes
1answer
38 views

Linux Bash Script File Search for Log File

How would I go about writing a Linux bash script for the following? I need to search for a file of format [unique_number].log This file would exist within one of the following directories ...
0
votes
1answer
31 views

bash script to call two functions, consecutively, each with its own argument

There are a lot of similar questions, but I cannot find an example of what I am looking for, nor in the Bash scripting guides (I'm sure it's there but its a big book...) What I want is this: I have ...
0
votes
1answer
30 views

How to stop tail -f except using kill

I want to write a shell script to detect if my program starts up successfully. There is a log file created by the program. When the log file contains a new line: Server startup in, then stop the bash ...
1
vote
2answers
134 views

Run .sh file on double click on Windows with Cygwin

I created a .sh script file on my Windows machine. I'd like to run it on double click. If I open up the Cygwin Terminal and start it manually with the “sh” command it runs without problems. When I ...
1
vote
2answers
60 views

Given key-value content, how do I group values by key and sort by value?

I've the following sample input format (file or stdin): key1: 1 key2: 2 key3: 3 key1: 4 key2: 5 key3: 6 Is there any few-liner which can group values based on the key and then sort? Expected ...
0
votes
1answer
18 views

How can I append text in the middle of a pipeline?

With cat its possible to append a file to the data passing through a pipeline: foo | cat - somefile.txt | bar Is there a command that lets me append text without using an intermediate file? foo | ...
2
votes
1answer
58 views

UNIX, how to compare and transfer values between two text file

I have two text files with different number of columns in them and I want to compare values of a given column in file1.txt with values of a given column in file2.txt: if these values found in ...
0
votes
2answers
29 views

How can I create a shell script shortcut?

I'm using Debian and there's a user who has a script called start.sh. I want the user to be able to call the script by typing application ... instead of ./start.sh ... I've been playing with symbolic ...
1
vote
1answer
63 views

How can I elevate my cmd prompt using the the cmd line

I follow this script "runas /profile /user:administrator\administrator cmd"and when it prompts me for my password it always says that it is incorrect even though i am spelling it correctly. help ...
0
votes
0answers
12 views

Zipping folders and using the folder name in the archive [duplicate]

I have a bunch of folders in a directory. I'd like each one zipped in it's own archive and the source folder should be deleted. So if my source folder has: Folder1/ Folder2/ Folder3/ After the ...
0
votes
1answer
32 views

Remove a specific string common in multiple lines in a CSV file using shell script

I have a CSV file which contains 65000 lines (size approximately 28 MB). On each of the lines they have a path in the beginning in the format of: c:\abc\bcd\def\123\456. Now let's say the path ...
11
votes
4answers
1k views

Who deals with the star * in echo *

Who deals (interprets) the * in echo * Does the echo see the star or the shell take care about it and return a list of filename .. What about cp temp temp*