A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.

learn more… | top users | synonyms (2)

2
votes
2answers
463 views

How to execute “Yes/No” operation as long as I press “Yes” in bash?

Suppose I have the Yes/No construction in bash script: read -r -p "Yes or no?" response if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]] then do ... else exit 0 fi I want this construction to be ...
0
votes
1answer
44 views

Few questions about realization of commands using bash scripts

I'm the newbie into scripting, so, please, sorry for annoying questions. I need to create bash script file, which after its launch does following. 1) Suppose after launching the script I enter the ...
1
vote
3answers
94 views

Is there any way of speeding up this DNS script I made? [closed]

Part of my work is doing a lot of different DNS lookups, so I created a script that displays the information that I need in a neat fashion. Problem is it's not very fast. Doing a bash -x I can see ...
1
vote
0answers
21 views

Systemd and controlling network settings

I'm trying to figure out best way to control network settings in best way possible in real time. My current plan is this: Start ip -s -d -o monitor with systemd and write its output to file ...
0
votes
0answers
42 views

script to delete files when it cross limit size

I want to make a script which delete files when it cross 70% usage. In directory there are logs files has 9.6 MB size. I want that if directory cross 70% then it find oldest files and delete them. ...
3
votes
2answers
94 views

Debian (jessie) with XFCE, Sessions and Startup: Application Autostart

Long-time lurker, first time question-asker. I am running Debian jessie with XFCE, kernel 3.16.7. In the course of setting up Conky to run at startup, I wrote a bash script to... well.. run Conky. ...
1
vote
2answers
57 views

How can I add a filter to my grep script to NOT include a string?

I'm working on a script that will separate the Registrar information from a domains whois. So far it's working enough but there are a few things that I want to remove in order for it to be a bit ...
0
votes
2answers
81 views

cut -c won't work on my .sh file [closed]

I have tried the following commands cut -c-11 ifshell.sh cat ifshell.sh | cut -c-11 ifshell.sh cat ifshell.sh | awk '{print $1} | cut -c-11 ifshell.sh But every time I get the full contents of ...
1
vote
2answers
42 views

How to execute a command when internet is back

Sometimes my wifi is connected to router but my router is not connected to internet. How can I execute a command when my internet is back (from command line)? I want to execute: mpg123 /home/user/...
0
votes
3answers
86 views

Efficiently compare If variable exists and is not equal

I have a problem with the sh script syntax. I wrote a script for my Asus router. The script works perfectly. But I have this line: if [[ "$OldIP" && "$StartIP" != "$OldIP" ]]; then echo OK; ...
1
vote
1answer
78 views

Script fails, but copy and paste from script works

I made a script to check the computer's processor count and then change all references of the processor number in another script in accordance with that.  I tested it first by copying and pasting it ...
1
vote
3answers
109 views

How can I compare different files without opening them?

I have two directories A and B; each one contains a lot of sub-directories geom001, geom002 ....etc each sub-directory contains a file named results. I want to compare, without opening any of them,...
3
votes
1answer
70 views

Rename files based on JSON content

I have two sets of files; file1.txt file1.json file2.txt file2.json file3.txt file3.json ... fileN.txt fileN.json json files contain the following format: {"ago": "59 sec ago", "...
1
vote
1answer
37 views

find matching URLs in a line, then shorten them to the domain name

I am new to the Linux command line and need some help. I have a log file I am writing a script for so it only shows certain fields of output. The last bit I need is to shorten the URL's so that it ...
0
votes
3answers
65 views

How can I subtract two variables in bash?

Hi Guys am getting error please help to sort out. I am new to scripting Script: #!/bin/bash value='55' size=`df -kh | grep '/vol/cdr/MCA' | awk '{print $5}'| sed 's/%//g'` if [ "$size" -gt "$value" ...
0
votes
0answers
23 views

What is the difference between '[' and '[['? [duplicate]

(Hope this is no duplicate) So I have a part of script like this: $ a='f' $ [ $a = [fF] ] && echo yes || echo no no $ [[ $a = [fF] ]] && echo yes || echo no yes So, why do the ...
1
vote
1answer
46 views

How to follow the activity of one specific file [closed]

I have currently MAAS deployed on one of the servers. It all works (most of the time). Now I have added some lines in the WOL file for MAAS (/etc/maas/templates/power/ether_wake.template). I wanted to ...
1
vote
1answer
38 views

How can I edit my bash script to account for whitespace entries? [duplicate]

I made a script to automate ffmpeg conversion from mkv > m4v > open the m4v in Subler.app to import the metadata manually, at which point I'll move the file into my iTunes library. I use iTunes ...
3
votes
2answers
40 views

Collate image list with name

How to create a collation of images in the format: image_name_1 [IMAGE#1] image_name_2 [IMAGE#2] image_name_3 [IMAGE#3] ... Using Imagemagick I can say something like: montage -label '%f' -mode ...
0
votes
2answers
50 views

pausing a loop in AIX to wait for user input

I'm searching for a scripting mechanism that can realize the following idea. Loop over a list and stop/wait on "read x" until the next input from a user. I know the following script is not working! As ...
3
votes
2answers
27 views

Improving execution speed of Screen Brightness Script

xrandr --output LVDS-1 --brightness $(bc -l <<<"$(sed 's/Brightness: //' <<<$(xrandr --prop --verbose | grep Brightness)) $(if [ "$1" = "+" ];then echo +;else echo -;fi) 0.1") I ...
2
votes
1answer
30 views

Silhouette from an image

How can I create silhouette from an image in linux using the terminal? By creating silhouette I mean - how do I turn the RGB components values of an RGBA image to #000000, while preserving the alpha ...
-5
votes
1answer
75 views

Shell script to delete logs when the disk space reaches 90%

I need help to develop a shell script to delete the logs automatically once the disk space reaches 90%. I can add this shell script to crontab jobs.
0
votes
1answer
16 views

linux command has different behaviour in script

(Question SOLVED and edited for helping someone else that need it or have the same mistake, now with the code in the post for better readability) I am trying to create a script that does something if ...
1
vote
3answers
37 views

How to add the aggregated numbers in a file

I need to write a script which will add the values for the same string in different lines. For example when a file contains the following: abc,10 xyz,20, abc,30, ghd,40 xyz,10 script should check ...
4
votes
0answers
62 views

Check if a remote machine is in a cluster

How can I verify if a remote machine is a cluster machine? I just created the following ssh command to verify if the remote machine is a VRTS cluster or a Linux availability Red Hat cluster ...
1
vote
3answers
39 views

Script or command to list all top-level directories that contain sub-directories with modified files less than 30 days old

This is quite a unique one. I'm looking for a way to list all top-level directories in a folder that contain sub-directories with new or modified files less than 30 days old in them. We use a ...
0
votes
1answer
45 views

Bash script fail to detect disk

I got a script that is supposed to reformat and mount /dev/disk/by-label/backup_disk into /mnt/backup_disk. Like this: /sbin/mkfs.ext4 -q -L backup_disk /dev/disk/by-label/backup_disk mount -t ext4 /...
0
votes
2answers
40 views

Script input filename or standard input

#!/bin/sh read vstup if [ -f "$vstup" ] then cat $vstup else if [ $vstup = "-"] then while [ $stadvstup != "q"] do read $stadvstup >> temp.txt ...
1
vote
2answers
26 views

Script - numberlines

I would like to make a script, which allows user to input some text and it will output the same text with number of lines. Example: Input: Hi Jack, how are you? Output: 0001: Hi Jack, 0002: how ...
1
vote
1answer
119 views

Safe way to install .sh script in /usr/local/bin?

I want to include correctly the following script in Ubuntu 16.04. Code #!/bin/sh # http://tex.stackexchange.com/a/20886/13173 # $Id: pdf2eps,v 0.01 2005/10/28 00:55:46 Herbert Voss Exp $ # Convert ...
1
vote
0answers
25 views

Access to bash arrays in gnuplot [duplicate]

In a bash script I have several arrays which I need to access in a gnuplot code: #!/bin/bash ... # fill array a[*] and b[*] ... gnuplot <<EOF do for [j=0:10] { # access ${a[j]} and ${b[j]} } ...
-3
votes
1answer
64 views

Need help in a shell script

I need help with the below shell script. I have three environments: test, dev and prod. When the user enters test it should ftp to test host and ftp the file. Same in case of dev and prod. I have just ...
1
vote
0answers
14 views

Linux Mint Corners Musical Sequence Associative Array

I am writing a script which uses hot corners to play specific musical notes when hovering in corners, and depending on the musical sequence to execute a specific command. The script is called with ...
0
votes
2answers
75 views

Using regular expression to extract content of file [closed]

I have a link and I would like to return only content between www. and .com e.g www.blablabla.com would return only blablabla How could I do that? When I use grep '\.[a-zA-Z0-9\.-]*\.' it gives me ....
1
vote
1answer
129 views

Evaluation of find ( -exec )

I'm searching for all files that contain one of a set of strings. If they do, I change their access rights. find . -type f -exec grep -q '#!/bin/bash\|#!/usr/bin/grep\|#!/usr/bin/awk' {} \; -exec ...
6
votes
1answer
270 views

How to use less in a script without getting ESC escape characters?

When I use less at the command line the output is like but when I use less from within a bash script I get: How can I use less in a bash script and not get all the escape characters and have it ...
0
votes
1answer
22 views

Filtering time using last command on Solaris

I'm connected on server using Solaris and need to filter only people who were connected there until 28.4 00:00. How do I do that on Solaris? In bash I have -t option which does what I want.
4
votes
2answers
61 views

Best way to delete select email messages from mbox file using script

I have an arbitrary email messages file in mbox format. I would like to periodically (end of the week), and automatically (via cron) purge messages from my "alerts" mbox file (new folder) just from ...
0
votes
1answer
49 views

Script too slow ? Any particular reason?

I have a script which does hexdump along with pipeline commands and finally I am redirecting it to a file. Now I am logging data from the serial port of my Raspberry Pi. I also call a python script(...
-1
votes
2answers
47 views

Where can I practice my Python and Bash scripting? [closed]

I wanted to practice my bash scripting skills and python skills and wanted a good book or a site where I can practice and get excellent skills please. Any recommendations please.
1
vote
1answer
72 views

Trying to copy/paste long script with multiple EOFs, Terminal starts running half-way through

Was trying to create a text block that I could just copy and paste into a Terminal window to accomplish something (in this case, create a systemd script to do maintenance on MySQL dbs, create a timer ...
1
vote
1answer
58 views

Bash print current line, line's output, and linebreak to file

I've got a txt of a bunch of domains I need to run dig +short mx on. I've got a script set to run the command, print it to a results.txt with: ./dig_domain_mx.sh > results.txt Downside is, I ...
1
vote
4answers
40 views

Compare characters

I have two lines, which are saved in two variables. But it doesn't really matter, where they are saved. My question is, how do I compare each character from both lines? For examples Hello Hlleo ...
1
vote
0answers
21 views

Script - printing specific lines [closed]

I would like to print every line from text file with for loop, but somehow it doesn't work. It writes error: head: invalid option -- 's' I haven't used 's', so why it output with this error? #!/...
0
votes
3answers
24 views

Getting the first 5 characters of unix filenames

I have Unix filenames like the following and I need to extract the first 5 characters of the filenames. I know you can use cut to extract the field content but I’m looking for getting the first 5 ...
-1
votes
1answer
25 views

adding date to beginning of file name using script

I have multiple files that need to be renamed with a date added to the beginning of the file name that I am trying to script. I'm using the cp command because I need to keep the original file I need ...
-2
votes
2answers
75 views

Keep CPU busy at certain percent (to prevent CPU buzzing frequency noises) [closed]

On Dell Inspiron 7559 there is electric buzzing from beneath the keyboard that changes frequency when I touch the touchpad. However, if the CPU is busy I hear no buzzing as the frequency gets out of ...
0
votes
0answers
60 views

Executing remote code with arguments

Why this: ssh -i ~/.ssh/master.pem ec2-user@xx.xx.xx.xx 'bash -s' < `dirname $0`/elements/"$element" returns hostname.sh test-5000: No such file or directory when $element is not a just a single ...
0
votes
2answers
52 views

List Most Recent File per Sub-Folder

I have a File structure of : FOLDER/SUB_FOLDER/Text_File I have over 1k+ FOLDER and each FOLDER has at least 2 different SUB_FOLDER with each SUB_FOLDER their own Text_File. I'm trying to ...