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
45 views

How to create shell script to handle commands like ls -l /somedir

My script so far can handle the ls command and returns the files in the directory. Now i am trying to make it handle commands like ls -l /tmp . Any help? My script so far: #!/bin/bash #set -x clear ...
3
votes
2answers
65 views

How to keep exactly one file in a directory?

I have recovered files and currently they have this structure: root/MD5_of_file1/file1 root/MD5_of_file2/file2 ... root/MD5_of_filen/filen Obviously, duplicates are now in the same folder. The ...
0
votes
0answers
30 views

Shell script to kill process using more than X %cpu after X time

I am in need of a sh script that will auto kill a process that is using more than X %cpu after X minutes. I did some search but none of the scripts I found work. Can anyone help me? Thank you!
0
votes
1answer
23 views

Mysql init.d to systemd

I have two mysql instances on a centos 7 machine. init.d handles start on boot. problem is, only one instance starts on boot. both instances uses two different ports. Can someone help me with how to ...
3
votes
1answer
180 views

is there a way to get the url from current tab in google-chrome?

I used to do that on firefox using a python command, but recently something changed and I can't get the URL anymore! What used to work with firefox: #!/bin/bash current_tab_num () { python2 ...
1
vote
4answers
81 views

I need to make a file undeleteable, but allow it to be modifiable and renameable

I have a script that checks for the presence of a file, and if it exists, read a list of email addresses from it to send notifications. When I don't need to be notified, for instance, when I'm at work ...
1
vote
1answer
62 views

Compare 2 Columns in 2 different files

I need to subtract second and third columns between 2 files based on the first column and do not show rows with diff_column_2(DIFF-IO)=diff_column_3(DIFF-SELECT)=0. Noting that the order can be random ...
0
votes
4answers
37 views

How do i write a script to run only if another script has run more recently?

I am attempting to write two scripts. But i run into problems when i try to prevent either one of them from running twice in a row. For example, i have script1 and script2. i want to be able to run ...
-3
votes
1answer
24 views

What is the correct expression to generate the correct result? [closed]

This script takes a CSV file and iterates over it to create a MD array. It then takes the third column and compares each variable to determine if it is greater than 64. I can get it to work if I use ...
1
vote
1answer
42 views

migrating to systemd a startup-shutdown script that works with tmpfs and bindmounts

BACKGROUND INFORMATION : I have an init script that allows me to mount a folder to tmpfs, while bind-mounting the folder on drive to another location, so I can sync the contents (on startup, ...
-1
votes
1answer
41 views

$* \ ||, eval and "\; mean?

Could you please explain the below code? What does $* \ ||, eval and "\; mean? Here below are the functions Initialization_variables error_message quit_error_chk Initialization_variables $* \ || ...
0
votes
1answer
33 views

Is it possible to sftp to multiple machines in single sftp command? [closed]

In my case, I want to sftp set of files to 3 machines using 1 sftp command in RHEL. Is it possible?
0
votes
1answer
105 views

Execute a command every minute forever using 'date'

I'm looking for a way (bash script or other) to make a command run every minute using date - I've been looking around for similar solutions but they all suggest either cron or watch but what I want to ...
2
votes
1answer
89 views

Bash script unable to move files

I'm trying to write a "janitor" script that will run as a cron job in one specific directory. It is supposed to create an archive folder with the date of creation in the name, and then find and move ...
0
votes
3answers
33 views

i want to print the line which starts with a paricular word and in the rest records print only 1st field

for eg: CREATE TABLE MWWDATA."VTCat02" ( "ID" NUMBER(10) DEFAULT NULL , "Cat" VARCHAR2(255) DEFAULT NULL , "Style_Code" VARCHAR2(255) DEFAULT NULL , "Vendor_Style_#" VARCHAR2(255) ...
1
vote
1answer
79 views

how to make scripts that shows Western Zodiac?

I want to make scripts that shows Western Zodiac which accepts as input a person's birthday on the command line and prints out the following: The day of the week on which the person was born Their ...
1
vote
0answers
102 views

Slow script execution

I have a strange problem... My script: #!/bin/bash SECONDS=0 lock_file=/tmp/$0.lock [ -e $lock_file ] && exit touch $lock_file echo "<<<db2_hadr_check>>>" instances=( ...
2
votes
1answer
229 views

use 'mail' to read email from command line

I know we can use mail command in terminal to start using the mail program in interactive mode. However, I want to read the email using mail command non-interactively. Is there a command like $ ...
1
vote
1answer
69 views

Script not working but command works outside of script

I have a very simple script that basically runs a command and then emails the report to a user: #!/bin/bash FROMDATE=`date -d "last week 13:00 " '+%Y-%m-%d'` TODATE=`date '+%Y-%m-%d'` ...
1
vote
1answer
161 views

Get the output from expect script in a variable

I have an expect script which provides the IP address: #!/bin/expect -f set nodename [lindex $argv 0] spawn virsh console $nodename expect "Escape character is" send "\n" expect "localhost login: " { ...
1
vote
1answer
158 views

Syntax error near unexpected token done when looping a multi-statement line

I have the following code as part of a larger file (assume ${tools_urls}, ${tempFolder} are global variables) download_tools() { for i in ${tools_urls}; do wget --no-check-certificate ...
0
votes
2answers
40 views

Sort list of currently logged in users and display one line containing the userid that sorts last?

Question is in the title. Sort list of currently logged in users and display one line containing the userid that sorts last? Feels like it should be simple, but I'm having trouble coming up with the ...
0
votes
2answers
14 views

Creating directories & subdirectories based on user input than display created directories?

Okay so I'm learning Linux in college. I'm really not that good, and want to improve a lot so bear with me. I wrote this code: Yes I know this code does not work, but maybe I can get my point across. ...
0
votes
1answer
56 views

How do I get a Debian server to output “screen -ls” on ssh login?

I read that I can add a line like this to /etc/ssh/sshd_config: ForceCommand /etc/ssh/loginscript.sh The "loginscript.sh" is executable and only does screen -ls until now. I suppose the problem is, ...
1
vote
1answer
67 views

passing sftp commands to sftp connection in a file

How can I pass a script to an sftp connection? e.g. I make the sftp connection thus: #sftpscript.sh serverIP="1.2.3.4" sftp $serverIP So far so good. Now I have a script the looks like this: ...
2
votes
2answers
515 views

using sudo -u <name> to run commands inside shell scripts

I'm extremely lazy, and prefer to write scripts to automate compiling software. To me, as these scripts can get quite long, it's easier to run them as root but have the individual software compile as ...
2
votes
2answers
69 views

Are there any sed scripts built in to mainstream Linux distros?

When I was studying bash, I found it very helpful to go and study the bash scripts already present on a clean install of Linux—/etc/profile, for instance, and anything in /etc/rc.d/init.d/. These are ...
1
vote
3answers
69 views

Downloading a few thousand files - how?

I want to download a few thousand files one by one. The average size of each one is 5-10Mb. Each has a name of "name_{i}", where "i" is a counter. What's the easiest and best way to do that? Note ...
0
votes
0answers
26 views

How to quote for Maildrop's xfilter?

I am trying to setup up a filter that resolves these "Re: AW: Re: Rif: Subject..." catastrophies. if( /^Subject: (Re: |AW: |Antwort: ){2,}/ || /^Subject: AW:/ || /^Subject: Antwort:/ ) { ...
7
votes
3answers
74 views

Remove certain characters from multiple files with whitepsaces

I'm trying to rename a bunch of music tracks in a directory, but I got this error: When moving multiple files, last argument must be a directory This is the script: for file in * ; do mv ...
2
votes
0answers
22 views

Automation: Autorearrange/reorganise Desktop Icons

I'm running Linux Mint 17+ on a laptop and I insert and remove external drives quite frequently. There are a varying number of other icons on my desktop, which I prefer asthetically pleasing, and they ...
5
votes
2answers
25 views

maintain prompt despite ouput flow

Short version Can I maintain an input symbol (> for instance) at the bottom of the terminal so that the user can input despite text flowing above? Long version I am making a multi-process ...
2
votes
3answers
209 views

bash - get pid for a script using the script filename

I have two scripts: running_script script_one I need to get the PID for the/any instances of running_script running under a username, and then pkill to stop the running_script and daughter ...
0
votes
2answers
25 views

Im trying to pull all the text past one point in a file and print it on the screen using bash

This is my input and output cat /home/$USER/Downloads/cudaHashcat-1.37/cudaHashcat.pot | grep : ...
4
votes
2answers
125 views

Read quoted array elements with spaces from file?

I'm passing data from STDIN into an array using read like so: prompt$ cat myfile a "bc" "d e" f prompt$ read -a arr < myfile But read doesn't appear to pay attention to the quoted strings and ...
3
votes
1answer
61 views

Is there a way to activate a particular tab of chrome via bash?

Suppose, for example, I have a chrome window active with gmail opened somewhere among its tabs (but not necessarily the active tab). Question: Is there a way to activate the gmail tab from the ...
4
votes
3answers
130 views

Use terminal-based documentation effectively (no web browser) [closed]

The problem I was trying to find shell scripting information without an Internet connection, i.e. via man page. Specifically, I was looking how to pass and use parameters. man bash does not contain ...
2
votes
3answers
38 views

need to move files with name into directories with corresponding names

I have files named patient_sample_L001_R1_001, patient_sample_L002_R1_001, patient_sample_L003_R1_001, patient_sample_L004_R1_001 another set named patient_sample_L001_R1_002, ...
2
votes
1answer
81 views

How can I get the correct end time of a nohup command?

#!/bin/sh set -x echo "Starting Time at "`sshpass -p xxx ssh -o StrictHostKeyChecking=no UN@IP 'date'` nohup ab -n 20000 -c 70 https://xxx.xxxxxx.com/xxx/xxxx/new.jsp & echo "Ending Time at ...
1
vote
2answers
66 views

Linux; run script when a specific host becomes reachable (logs in on AP)

I have a Debian Linux running on a RasPi. I'm looking for a way to run a script when another system becomes available on the network (aka logs in on my wifi AP). The AP is an AVM Fritzbox and as such ...
-3
votes
1answer
67 views

Please help assess what's wrong with my script

I'm attempting to create a script that loops through an entire directory of files in order to find the file with the most characters in that directory attached is my code sample. What am I doing ...
2
votes
1answer
73 views

Conditional Execution - Launching Persistent Sub-Processes and Coroutines

Conditional execution is used in Bash to control the flow of a script on the basis of the exit status of a subprocess. However, there are situations when a subprocess (application) is launched in the ...
2
votes
2answers
45 views

Help required to execute shell script

I need to write a shell script to see if the ADM Process is down we need to get an alert via email. I have done that using the script below. It is working fine if we have installed one ADM server on ...
0
votes
3answers
47 views

Need to write a “thirsty.sh” script: BASH [closed]

Okay I have all of the code and it's working. I am just having trouble with the while loop #asking the user if they are "thirsty". echo "Are you thirsty?" #creating thirsty variable read thirsty ...
-4
votes
1answer
36 views

Need to write “pickanumber2.sh” script [closed]

Name the script pickanumber2.sh. The script will get a random number 1 - 100. Ask the user to pick a number. If the user picked the correct number, tell the user. If not, tell the user if they were ...
2
votes
1answer
67 views

Unix ffmpeg Shell Script merge .aif and .mp4

I need a script that merges multiple files (.aif and .mp4) in the same folder with the same name to a new folder called [original_name]_new.mp4 Code: #!/usr/bin/env bash -e function combine(){ ...
1
vote
1answer
102 views

Skip first line (or more) in CSV file which is used to rename files

I have used the info from another question on Stack Exchange to allow me to rename files using the info in a csv file. This line allows me to rename all files from the names in column 1, to the names ...
2
votes
1answer
72 views

Cut command does not separate by tab in script

Note : I don't know how to insert tabulation in my text, I replaced it by [tab] I have a list file name value separated by a tabulation : host1[tab]ip1 host2[tab]ip2 host3[tab]ip3 host4[tab]ip4 ...
2
votes
3answers
57 views

Bash script to echo the first positional of each line into file with name of the second

I have a text file that is organized as follows: Group 1 asdsdsdsdf.html jeff xcvxcvxcvx.html bob vrgeiuvhif.html sue Group 2 iwdowijdoi.html mary pokpompojm.html doug ndkjfsjfbs.html lisa I ...
6
votes
6answers
661 views

bash: how do you return file extensions?

I want to write a script to return just the extension of the input file name. For example, textfile.txt should return txt. I'm new to Linux and bash, and I'm trying to learn how to write basic ...