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
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 /...
0
votes
2answers
38 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
93 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
63 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
73 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
126 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
259 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
21 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
54 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
43 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
53 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
53 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
39 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
24 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
68 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
58 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
50 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 ...
6
votes
3answers
83 views

sed/awk subscript numbers in chemical formulas using markup tags

I have hundreds of text files that include chemical formulas together with narrative including numerical values. The formulas are always preceded by white spaces but can be followed by white spaces, ...
0
votes
1answer
36 views

How can I avoid being prompted for a password in this script? [duplicate]

I’m using Amazon Linux. If I login as my “otheruser” user, and create a script, test.sh, with this text sleep 5 ; sudo reboot now I can login and run the script like so … [davea@mydevbox ~]$ sudo ...
0
votes
1answer
36 views

Source ~/.bashrc when using the shell recorder `script`

I am using the first answer from How to automatically record all your terminal sessions with script utility to record my terminal sessions, however, I can not figure out how to get my bashrc to be ...
0
votes
1answer
140 views

Parse xml returned from curl within a bash script

I've been digging through stackexchange for the past few days and I've found bits and pieces of what I'm trying to accomplish, but I'm unsure how to put it all together... I'm trying to create a ...
1
vote
1answer
102 views

How to Wget with Subset Condition?

I want to download a subset of data recursively in the website that is within HTML class .container current main page in .container daughter pages of links also in .containers in daughter pages ...
3
votes
1answer
56 views

How to revoke access for a particular user?

How can I revoke all access (r,w,x) for a particular user to a file or directory tree (while still giving read permission to others)? Does setfacl with mask allow this ?
0
votes
1answer
23 views

Script which reacts to interrupt signal [duplicate]

How to make a script, which will write a string "signal caught" after sending 'interrupt signal' (after pressing ^C on the console, where the script was executed). On top of that after pressing third ...
-3
votes
1answer
90 views

Script to clean log files does not delete them

Could someone explain to me why this script does not delete /var/logmessages and /var/log/wtmp files? I found it on tldp.org tutorial #!/bin/bash LOG_DIR=/var/log cd $LOG_DIR cat /dev/null > ...
0
votes
0answers
21 views

Automated port change

I want to Create a Bash file that a user can execute to change the port a service runs on. Essentially all I have to do is replace a number in a line of text with another number generated by a list. ...
0
votes
1answer
21 views

The unalias in the Mysql Backup script

Here's the script to back up Mysql database. #!/bin/bash FILE=minime.sql.`date +%F` DBSERVER=127.0.0.1 DATABASE=wordpress USER=root PASS=789789 unalias rm 2> /dev/null rm $FILE 2> /dev/null ...
1
vote
1answer
21 views

Mean and variance of words pronounced

I'm working on linguistics and am trying to calculate the average sentence length and how much this average varies. I worked to leave always one sentence per line For instance: La dernière fois ...
0
votes
2answers
37 views

Copying script files using wildcards

We have an SFTP location which is shared by two processes. Now we have a situation when we need to filter based on the filenames before copying. ClientA12345.out ClientA44378.out ClientB23478.out ...
0
votes
0answers
13 views

Bash script not passing variable through ssh [duplicate]

I'm trying to write a script that will ssh into multiple servers and echo the line user_pref("plugin.state.java",2) into every user's firefox pref.js file. I keep getting the error bash: /home//....
3
votes
2answers
135 views

How to extract strings from one file into multiple files

I have a file, xxx.lst with the following data: aaa 111 bbb 222 ccc 333 I need to make 3 files called 111.lst, 222.lst and 333.lst respectively with aaa in 111.lst bbb in 222.lst and ccc in ...
0
votes
1answer
60 views

Copy last n-lines from one file to another

In the context of adding the same lines at end of the .bashrc or .vimrc files of several user accounts on the same machine, what would be an easy way to copy the last n-lines from one shell script to ...
0
votes
1answer
23 views

Count ONLY alphanumeric words in a specific column of a file

It's essentially what the title says - I'm given a test file and am supposed to be able to count the words in a specific column of a file. The catch is that there are some lines that contain only ...
0
votes
2answers
47 views

Command to merge all terminal windows?

Is there a terminal command that merges all open terminal windows into one window with tabs? Been searching all over the place, but have yet to find any solutions.
-1
votes
1answer
33 views

negation equivalence

I have this exercise: Write a script, which uses if-then-else-fi and accept sequence of parameters -a and -b with values "true" and "false", while for every pair writes negation of expression -a <=...
0
votes
1answer
43 views

How to execute a script on SSH Login or device bootup/shutdown? [duplicate]

I have a raspberry pi, which is online and connectable by SSH. What I want to do is create hooks for the following states: When the device starts Before the device shuts down When an SSH login ...
1
vote
1answer
46 views

How can I get my bash script to remove the first n and last n lines from a variable?

I'm making a script to preform "dig ns google.com" and cut off the all of the result except for the answers section. So far I have: #!/bin/bash echo -n "Please enter the domain: " read d echo "You ...
0
votes
2answers
251 views

Unable to execute bash script inside expect script

i have a expect script like #!/usr/bin/expect ..... spawn passwd expect "password:" send "password" .... .... .... ~/test.sh Wile executing this, I'm unable to run bash script test.sh. How to ...
-2
votes
1answer
68 views

quick and easy way to comment out multi lined print statements

Is there a quick and easy way to comment out multi lined print statements? something like this? printf("3387 strings_line_tokens[lower_bound_of_big_boy_counter] %s \n", ...
0
votes
1answer
43 views

practice linux for practical use [closed]

I have learned and studied linux for 6 months with books like 'The linux commandline'. But, I'm just student, not a business man. When I study linux and do not use it for long time, I always forget ...
3
votes
1answer
44 views

Why does this fish script does not run from a launcher?

I've written the following script, intended to start a daemon and display a Zenity window, then stop the daemon when the window is closed: #!/usr/bin/fish if not ps aux | grep [s]erviio > /dev/...