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
1answer
13 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
2answers
69 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
37 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
16 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
23 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
47 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
17 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
48 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
57 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
27 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
26 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
29 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
62 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
44 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
17 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
42 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
27 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
55 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
18 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*
0
votes
1answer
13 views

Use of variables withing singlequotes, CSH

I have a short script meant to do some server maintinence, but I can't for the life of my figure out how to properly use variables within my script, Here's a code sample to make it more clear: ...
0
votes
0answers
15 views

Copy from SFTP to local host using Username/ privatekey.ppk using powershell

would you please help me , i need script that copy files from FTP server to local host using only Username and .ppk as a private key , i don't have password. is it possible to do that. Please ...
0
votes
0answers
32 views

OS X Automator to create a set of folders based on list in a text file

I'm a Terminal and Automator novice. I have found a terminal command that allows me to create a bunch of folders from a text file formatted as following: "Folder Name" "folder Name Two" "Another ...
0
votes
0answers
14 views

Execute commnad after server started in other pane with tmuxifier or tmux

I have a window with several panes where I execute commands to start the servers. I want to be able to execute commands after a server is running. To run commands in the same pane is not possible ...
2
votes
0answers
34 views

How do I record in VLC media player on a schedule?

I have an IP stream coming through VLC media player in Window 7, and I would like to automate the process of opening the stream and start recording at a specified time, and stop VLC and the recording ...
0
votes
0answers
20 views

shell script to generate a log file for VM Backups

we are using PHD virtual backup to trigger backups for VMs and now i want to generate a report of all VMs in a file consisting of VM Name, Date and Backup Time and mail it to my ID at particular ...
-1
votes
1answer
46 views

How to switch to another user from SSH?

I am looking for a command to SSH to a server using root and then switch it to other user after executing SSH. Could someone please help me in providing the command for this. Not Working: ssh ...
0
votes
3answers
88 views

Print previous 20 lines of text from a certain point of a text file

Currently: I'm new to scripting, teaching myself as i go along and this is my first script I'm developing. What my script is trying to do is look at specified file, scan the file to find the word ...
2
votes
1answer
79 views

How can I check if a file is newer that the target file in a shell script

How can I check if a file is newer that the target file? In a shell script, intended to run on a Mac, I want to do something like this: #!/bin/bash if [ $SourceFile dateisgreater $TargetFile ] then ...
0
votes
0answers
14 views

Setting a CRON to be run on every 1st and the 3rd Monday

I need to set up a CRON job to be scheduled in every 1st and the 3rd Monday of every Month. I'm using the Plesk control panel for setting these as follows. Currently CRON runs successfully, ...
1
vote
1answer
83 views

Calling parallel ssh (pssh) in bash script

I can run commands in parallel on a list of machines using psshcommand. For instance to make a folder foo on several machines, listed in hosts.txt I can run: pssh -h hosts.txt -l MyUserName "mkdir ...
1
vote
2answers
39 views

Spaced string variable as command parameter inside shell script

How can I store a spaced string in a variable and use it as a command parameter inside a shell script? This is what I'm trying to do: DESTINATION='/mnt/External Harddisk' ...
-3
votes
2answers
45 views

Create windows script to traverse all subfolders of some folder, and delete a certain folder and all of it's contents if it exists [closed]

here's the trick. Supposing I want to free up some space, and run that script in F:\UnrealProjects, which has a bit over 50-60 subfolders, I would like that script to traverse all of it's subfolders, ...
0
votes
0answers
13 views

script not running from remote machine

I have a shell script file in one machine(say jupiter.prashanta.com) which basically runs vlc as user. When I run this file ./runVLC.sh , it runs fine. The content of runVLC.sh is #!/bin/sh su user ...
1
vote
1answer
66 views

how to run a user command from a script

I have to run a vlc command, which cant be run as root. I am logged in as root. I want to put the command in a script ( shell script ) and run the command. How can I do this.My script is ...
-1
votes
2answers
142 views

Value of variable set in 'while read' loop looses value outside the loop

The following code is a simplified version of the real life task. Of course I know that I could achieve what is done in this simplified example with a if [ ... ]. This is only to demonstrate the ...
1
vote
2answers
555 views

How to run a script after startup on Ubuntu 14.04?

I have scoured the web and tried numerous solutions. Nothing has worked for me so far, hence this question. I have a rails application that I run with mongrel_rails start -e production -p 80. That ...
1
vote
0answers
17 views

Grep from Log & Calculate then alert

I have a log file, which has the below lines in it. I need a bash script, which takes the values in Bold (4092.1M / 20.1G) & do the math & then alert from Zabbix [Eden: ...
0
votes
1answer
63 views

What do these parameters do?

What is the meaning of the switches and parameters of this command? exec su -s /bin/sh -c 'exec "$0" "$@"' root -- /opt/nsq/bin/nsqd Specifically the -- part and what exec "$0" "$@" is supposed to ...
3
votes
2answers
118 views

Loop in a script until file exists

I'm trying to have a script find a file in /tmp called sleep.txt but instead it keeps looping Here's what I have: #!/bin/sh set -x until [ $(ls -la | grep -w "sleep.txt" | wc -l) != 0 ]; do ...
0
votes
2answers
112 views

Unix Script: Wait until a file exists

I need a script that will wait for a (examplefile.txt) to appear in the /tmp directory and once it's found to stop the program, otherwise to sleep the file until it's located So far I have: if [ ! ...
10
votes
3answers
544 views

Programatically determine if an script is being executed on laptop or desktop?

Is there any reliable way to determine (programmatically) from within a bash script if it is being executed on a laptop or a desktop computer? I could obviously just prompt the user to ask them, but ...
1
vote
1answer
29 views

protect the known_host file from writing - good or bad idea?

I want to protect the known_host file from writing So I want to perform the following steps on my Linux red-hat server Cp /dev/null /root/.ssh/known_hosts chattr +i /root/.ssh/known_hosts I want ...
0
votes
1answer
105 views

How do I save a string of numbers from an ongoing command to a list in a shell script?

I am trying to make a shell script for recording macros via recording the individual keycodes of each button press. The command for it looks like this: xev | grep -A2 --line-buffered '^Key*' | sed ...
1
vote
1answer
143 views

Exit bash script when curl gets a non 200 HTTP status

I have a bash script setup to perform a few curl requests for currency in EUR INR JPY do curl -i --data '{"currency": "'$currency'"}' -H "Accept: application/json" -H "Content-Type: ...
1
vote
1answer
105 views

file exists not working in expect script

I'm trying to check if a particular line exists in filename on a host. So only if the particular pattern is found from the grep command a dummy.txt will be created. Then I want to check if dummy.txt ...
1
vote
2answers
29 views

Not creating new file while output redirection

I'm using this for output redirection: cat filename | grep 'dis' | wc -l > test.txt But I do not want a zero byte file created if no result is found from the grep command. Is there any way this ...
0
votes
1answer
222 views

cannot open `' for reading: No such file or directory

I am trying to run .sh file on RH6 and getting this error... cannot open '' for reading: No such file or directory The script I am running is internally referencing other scripts, located in same ...
0
votes
1answer
35 views

Executing Perl command from shell script not resulting into anything

I am trying to execute the below command from a shell script: perl -pi -e 's/Ç/|/g' diff_new_old.dat This command gets executed without any errors, but the execution doesn't do the intended ...