Questions tagged [scripting]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
43 views

How do you loop over files inside of loop?

I have a script like this: #!bin/bash for FILE in *.score; do plink2 --pfile Predix_chr22.doseN.new.pgen --psam Predix_chr22.doseN.new.psam --pvar Predix_chr22.doseN.new.pvar --pgen Predix_chr22....
1
vote
1answer
30 views

Writing logs for openvpn in Ubuntu18

I've installed openvpn on Ubuntu18, and it works. I'd like to have a log containing only the times when users connect and disconnect. Found a hint how to do it at [https://github.com/furlongm/openvpn-...
-1
votes
1answer
393 views

Shell script for telnet for multiple servers from text file

I am using below code for to telnet the multiple servers. file=ip.txt while read line do ip=$( echo "$line" |cut -d ' ' -f 1 ) port=$( echo "$line" |cut -d ' ' -f 2 ) if telnet $ip $port </...
0
votes
4answers
143 views

Deleting (some) comments from a C program

I need to use a bash script to delete full-line old-style comments from a C program, i.e., comments that begin (/*) and end (*/) on the same line, with no code on the same line.  This is an example of ...
1
vote
0answers
61 views

Setup Automation - Firefox and Addons

I am improving my setup script for new installs and want it to include setting up firefox. One big problem I found is, that it is not possible to install addons via CLI that automatically get updated ...
-1
votes
2answers
89 views

How come my script won't function properly?

I am trying to use my ./script.sh like so: ./compile.sh -n NAME_ALBUM -f 000 000 000 000 -l 000 000 000 000 where -n is ALBUM_NAME and corresponds to the outputted filename being saved where -f ...
3
votes
2answers
233 views

How to include custom command options in a bash script with $1 and $2?

I have a script myscript.sh #!/bin/sh echo $1 $2 which is used something like ... ./myscript.sh foo bar which gives me an output of ... foo bar but how can i make this script include custom ...
-1
votes
3answers
358 views

Variable for SCP command in script

I'm trying to write a script that will check what is the last modified/created file on the server, then copy it to my homedirectory on this server and then copy this file from node to my local machine....
0
votes
0answers
38 views

Repair a corrupted .odp file

I have a corrupted .odp file that cannot open anymore in LibreOffice Impress. There is no back-up available in LibreOffice (.bak file is missing). I was wondering if there are some powerful Linux ...
0
votes
1answer
106 views

Moving files to a bin [closed]

I am having issues with my code below: #!/bin/bash #Removing Files into the Recycle Bin(Deleted Directory) filemove=$1 #Saving the first argument as "filemove" mkdir -p ~/deleted #Create the deleted ...
0
votes
1answer
31 views

Find files and specify some to come first in playlist, and the rest in random order?

The following code creates a list of the files in the directory and then shuffles them in a random order then spits out the file in a text document called list.txt find *.EXT | sed 's:\ :\\\ :g' | ...
2
votes
0answers
133 views

Copying contents of a folder via SCP results in `scp: error: unexpected filename: .`

I was using a script to copy the contents of a folder via SCP, without copying the folder itself. Something like this: scp -i id_rsa -P "$PORT" -r "$HOST:/folder1/folder2/." "backup" (I'm not able ...
0
votes
2answers
45 views

Concatenate the Content of Files from Various Directories with a Blank Line in Between

I have the file dir1.txt that contains the names of the following directories: 2 3 4 Directory 2 contains files 2_1.txt and 2_2.txt Directory 3 contains files 3_1.txt and 3_2.txt Directory 4 ...
2
votes
1answer
171 views

POSIX and Portability | shell scripts | grep -s, grep -q

I am all in for portability in regards to shell scripts. But I am unsure if I am overdoing it right now. In this example, we have a function called confirmation, which accepts the very first ...
0
votes
0answers
9 views

UsbFlashDrive.getLabel meaning

reading through the system logs I can see those two messages USBFlashDrive.isMediaPresent - the media is present in the device USBFlashDrive.getLabel - Getting the label for the USB flash memory ...
0
votes
0answers
14 views

restrict cpu usage of chrome in ubuntu mate

I use ubuntu under virtual machine. whenever if i open too many tabs in chrome or firefox, system hangs. I found there are lot of utility to restrict the cpu usage. has anybody have ready made ...
-1
votes
1answer
25 views

Value addition from a file's row [duplicate]

Suppose I have one file like: apple | red | 2 apple | green | 3 orange | yellow | 3 apple | yellow | 1 Now I need following output as (irrespective of color value should get third number ...
0
votes
3answers
37 views

Can I assign multiple data entries to one variable & if so how?

I'm using Linux Bash/Shell and i would like to know how to assign multiple separate data entries to one variable. For e.g. list of teams. each team needs data of: total goals scored at home - total ...
0
votes
1answer
45 views

How to write an awk which reads a text and if it encounters a line starting with # (i.e. a comment line)?

It will add # followed by a space to the beginning of each following line until the end of the paragraph (paragraphs are separated with an empty line). The lines which already start with # are not ...
4
votes
6answers
4k views

shebang or not shebang

I want to use a program in the shebang, so I create a script named <myscript> with: #!<mypgm> I also want to be able to run <mypgm> directly from the command prompt. <mypgm> ...
0
votes
0answers
36 views

How can I kill my custom bash 'for loop' function with a keyboard shortcut?

I am trying to kill my custom bashrc function below: xmacroloop () { for (( i=0; i<$1; i++ )) do bash -c 'notify-send "Playing back xmacro_1 on $DISPLAY" ; xmacroplay "$DISPLAY" < ~/.cache/...
2
votes
2answers
107 views

script to automate luksHeaderBackup for multiple partitions

I have several servers each with at least six dm-crypt partitions. I would like to have an automated way to make sure I always have a luks header backup stored in a safe place. I've been making header ...
1
vote
2answers
50 views

Merging two files using matching characters

File1: X X P X N X Q File2: P 1 N 5 Q 0 Desired output: X 0 X 0 P 1 X 0 N 5 X 0 Q 0 I have tried a lot of ways using merge command on bash. I couldn't make it work.
1
vote
2answers
69 views

How to list all files less than 1080p

There are a number of Youtube channels that I archive using a daily cron script that runs youtube-dl. However, in checking over the videos to make sure my script is working, I noticed for one of the ...
0
votes
1answer
57 views

Find and Replace Recursive in xml file for blank spaces in email address

We are migrating an old environment to a new environment. The email addresses in the old environment could have blank spaces at the front or end. However, with the new environment, this is not allowed....
1
vote
1answer
41 views

Attempting to only copy files that have changed within the last day while maintaining folder structure

I'm attempting to find and copy files that have been modified within the last day. While doing that I'm trying maintain folder structures under dir1. There are many subdirectories under dir1 and data ...
0
votes
1answer
33 views

Find string and make it bold in output E-mail

i have below code which check status of some services on linux rhel 7 and send email (output is different service status). i want to make specific string called "up" and or "NOT up" in bold and with ...
0
votes
1answer
69 views

Rename files based on JSON content using jq

I need to make a shell script that uses jq to rename below mp4 file(s). (could have use jasonpipe but didn't know how to install it on mac) File Dowloaded: title1-1000221327.mp4 title1-1000221327....
11
votes
3answers
562 views

How to make a pipeline wait for end-of-file or stop after an error?

I tried the following command after watch this video on pipe shenanigans. man -k . | dmenu -l 20 | awk '{print $1}' | xargs -r man -Tpdf | zathura - It basically prints a list of manpages to dmenu ...
0
votes
1answer
18 views

How to create a process that runs a script until another process ends

I want to monitor the power that my system needs when i run a Benchmark. When the Benchmark ends the monitoring process should be killed . The monitor script is written in python. How do i do that?
1
vote
1answer
356 views

Convert json file to a “key-path” with the resulting value at the end of each “key-path”

I have a large and relatively complex json configuration file that I want to search for keys and/or values using simple tools like "grep". When I 'grep' the file I would like to have in the output ...
0
votes
0answers
53 views

How to run Rscript on multiple files to get table of separated outcomes named as original files?

I have written R script which takes a file from the folder. (CSV. files) The total length of the trajectory of a particular object is computed (one number). I have to do this process on all files in ...
0
votes
0answers
39 views

Comparing all combinations of lines within two columns using awk + if statement

I have a file with 11 Columns of data deliminated by a space between each. For each line in column 2, I need to find the closest value in column 9. So below it would take the first entry in column 2 (...
1
vote
0answers
33 views

How to capture all std outputs [duplicate]

Suppose I have a program called mktemp which creates a random tmp directory in /tmp and also produces a string output of the directory address Input[0]: mktemp Output[0]: /tmp/tmp.MkrKAscwwk How can ...
0
votes
0answers
27 views

Shell script to execute other script not spawning other scripts

I have a shell script running in a while loop. The script accepts a number as an argument so in ps you would see something like /path/to/script.sh 2. Every 180 seconds, it should be spawning a PHP ...
0
votes
1answer
86 views

How to print / echo positional parameters index

I have this working and simple code to echo positional parameters VALUES for i do echo "Argument = $i " done Here is the actual output from the scrip Argument = --atleast-pkgconfig-version Argument ...
0
votes
6answers
170 views

remove specific characters from a string

I need to replace spaces with comma and then remove certain extra specific chars from a string. echo "$d" >>Mon Apr 22 05:06:00 UTC 2019 jent=$(echo $jt1 | sed 's/[[:space:]]/,/g') echo "$jent" ...
0
votes
0answers
26 views

How to run 2000 processes with chroot

I have a program that needs to be run in about 1000 instances, each in a different independent directory (/mnt/x_1, /mnt/x_2... /mnt/x_1000). What I'm currently doing is mounting /bin /dev and /etc in ...
0
votes
1answer
35 views

Why my script is not working? [duplicate]

Hello I am trying to move a group of directories with the mv command and curly braces expansion as follows: #!/bin/bash ... group_name=$1 group=$((total/set)) group=$((group-1)) mkdir "$group_name""...
3
votes
3answers
125 views

How to temporarily disable sudo credentials timestamp timeout?

Let's say, I have the following bash script: #!/bin/bash sudo command1 command2 sudo command3 I don't want to run command2 as root, so I won't run the script itself with sudo. Therefore, as soon as ...
1
vote
1answer
47 views

Confused about determining if a shell script is running interactively

I only want to determine from my POSIX shell script, if it is running interactively, but for some reason, the following function: running_interactively() { printf '%s' ${-} | grep -F i > /dev/...
0
votes
0answers
41 views

How to set variables in nested ssh session

I want to set some variable in ssh session which is nested. ssh host1 << EOF ssh host2 << EOF1 myvar="Hello" echo=\$myvar EOF1 EOF What is wrong in this bash ...
0
votes
1answer
63 views

How to rename a file with different name? [closed]

I have a file named servername_test_LINUX_test_test_2019-04-19.xls I have to create multiple copies of this file, with the condition that server name should be changed in each file created e.g. ...
1
vote
1answer
56 views

korn shell - if a variable exists in an array stop processing without exiting

How would one evaluate priority of items in an array such that you only process the highest priority item that exists? Let me try to explain, if I had an array set -A array low medium none high ...
0
votes
3answers
209 views

Find and replace Pipe using awk command

I am trying to grep column 7th with pipe delimiter (|) data in that I have to removed pipe (|) from middle of text. Sample file: col1|col2|col3|col4|col5|col6|col7|col8|col9|col10 value1|value2|...
0
votes
1answer
54 views

How to automate a series of keystrokes involving two GUI applications

I have two windowed applications that I need to send a series of keystrokes to. I need to Alt-Tab back and forth between the apps, and I'd like to be able to reduce the number of keystrokes from six ...
1
vote
2answers
39 views

How can I read a txt file line by line and sort them by the correct variables and write them to another file?

Here is an example of my txt file John NY 2019 APR Mark SC 2019 JAN Ava CA 2018 AUG Here is the example of the target txt file Name,Location,Year,Month John, NY,2019,APR Mark, SC,2019,JAN Ava, CA,...
0
votes
1answer
29 views

Looping through all files, skipping some dynamically

rather new to unix. Trying to create a script to loop through all files and subdirectories given a directory and printing them. I would like to be able to skip certain directories dynamically though. ...
0
votes
1answer
160 views

auto enter password for `passwd <new user>` from script? [duplicate]

if the script was useradd ...............<new_user>; passwd <new_user>;. is there a way to put the new password in a script? I don't need to change or add an old password for an existing ...
0
votes
1answer
67 views

Find out if the connection to Wi-Fi was successful

I need to do some script, which find out if the connection to the Wi-Fi was successful or not. I have Wi-Fi configuration in /etc/wpa_supplicant.conf. I know how to add SSID and PSK to this file and ...