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)

1
vote
1answer
33 views

substitute at beginning of line

I want to search a pattern and insert a character at the beginning of a line using regsub in TcL. I have to use TcL only Input file mna1 x a1 vss vbn nch_svt_mac nfin=nfin_n1 l=ln1 mna2 x a2 vss vbn ...
1
vote
2answers
46 views

Compare string in two files And Merge its Output

I am trying to get the bandwidth of the domain from one file and its hits details from another file. The format of the two files is as follows: bandwidth.txt aadrivingschool.ws 2840.36M ...
2
votes
4answers
56 views

How do i find over 200K differently named files and output

We have a SAN with a lot (over 5 million) of files. Because of some freak mistake from a developer script, some files have been deleted and we now have to figure out which files got deleted. Now, I ...
-1
votes
0answers
28 views

Automating yum install using python

yum install (package-name) How can I write a python script to execute the command above and see if its successful or not? This should be the algorithm: run command yum install <package-name> ...
4
votes
2answers
66 views

Rename Multiple files gzips them and delete older than 10 days

I'm new to Linux/Unix and slowly learning it step by step. Unfortunately on today’s job interview was surprised by a task to do (which of course I didn’t know). I was asked to prepare a bash script ...
1
vote
1answer
37 views

Point and click Ubuntu 16.04 bash script randomly alternates output behavior

I wrote and tested the following point and click Ubuntu 16.04 bash script for the purpose of completely killing a mono-service RecorderManager.exe process by literally killing the process id returned ...
3
votes
1answer
61 views

How variables inside braces are evaluated

I'm new to shell scripting and I came across these expressions ${var:-val} and ${var-val} ${var:+val} and ${var+val} ${var:=val} and ${var=val} so how are they evaluated and what are the ...
2
votes
2answers
252 views

Run a ping command on list of servers and output to a file

I have a file servers.txt on a different server, with list of servers: server1.mydomain.com server2.mydomain.com server3.mydomain.com I want to first download this txt file, ping these servers and ...
2
votes
1answer
33 views

How can I use sed to snip a line off of a string?

I'm writing a script to display the domain registrar info and I'm trying to snip off a few lines from what I already have I currently have it grabbing all the indented text from a whois. Now I'm ...
1
vote
0answers
17 views

Change existing dovecot maildir installation from m-UTF7 charset to UTF8 to avoid breaking TAB

In an existing dovecot installation with many pre-existing folders using regional characters I would like to change m-UTF7 (.&AMk-l&AOk-ments envoy&AOk-s) foldernames to UTF8 (.Éléments ...
3
votes
1answer
33 views

How to automate mutt in removing old mailing-list emails?

In mutt I perform following sequence of steps: $ mutt -f imaps://imap.example.com username password [shift]+[D] ~C mailinglist1@domain.com [shift]+[D] ~C mailinglist2@domain.com (...) [shift]+[D] ~C ...
1
vote
1answer
29 views

'xz -d' vs. `unxz`

Why is xz -d preferred over unxz when writing scripts? From the man page for xz 5.1.0alpha: When writing scripts that need to decompress files, it is recommended to always use the name xz with ...
1
vote
2answers
51 views

Use variables in here-string

To feed input to an interactive script, I've been using a here-string: script <<< $'1 2\n3 4\n5 6\nq' This effectively enters 1 2 3 4 5 6 q into the script. But how can I replace one of ...
1
vote
2answers
31 views

Nautilus-script to move file into same name directory

How can I create a Nautilus script that moves a the selected file into a new folder with the same name? My starting point: /home/user/123 here 123 is a file with no extension My goal here is to ...
3
votes
1answer
56 views

Join arbitrary lines to output as one line

I want to join the 3rd and 5th line of a file to the output of a script without trailing new lines. Is it possible to implement this construction by using the code: { echo 'Some text' echo 'Some ...
0
votes
2answers
43 views

simple for loop script to build out ipv6 subnet

I am trying to use nmap to scan a /119 IPv6 network. (512 addresses). Before I do this I want to generate a file that will populate all of the ip addresses in that range. The network info is as ...
1
vote
1answer
33 views

detecting sound from speakers

I have decided to make a radio from my old laptop. I installed Puppy linux and set special features, like: after waking up, it turns on my favorite online radio (openFM) and switches off the screen. ...
3
votes
2answers
42 views

Looking for a convenient way to create a “constant array”

In zsh, is there a convenient way to create an array of n copies of the same integer? Context: In a shell script, I need to create an array, tile_lengths, consisting of two longish constant blocks. ...
-1
votes
0answers
39 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
2answers
59 views

Create blinking text with echo and escape characters [duplicate]

I have learned about formatting options used in shell scripting, which go like this: \033[37:40mAnyText\033[0m Now I want to echo some text like this: echo -e "SomeText \033[5;31;47mMoreText\033[...
0
votes
0answers
15 views

notify-send not showing when executing with sudo [duplicate]

In short: I have a scripting finding, fixing and mounting a partition, thus this needs sudo / su permissions. System: Gnome 16.04 - amd64 notify-send "a message" shows a notification as expected, ...
1
vote
1answer
33 views

SSH, Putty and sending data on the cluster

I have ssh access to the cluster through Putty. I also have the script, which, after its launch, makes some commands, generates data and sends it via email. Is it possible to provide following: I ...
2
votes
2answers
449 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
42 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
85 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
19 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
40 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. ...
2
votes
1answer
65 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
51 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
59 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
65 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
106 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
63 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
36 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
54 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
44 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
37 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
41 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
26 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
28 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
67 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
13 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
52 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
38 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
44 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 /...