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
2answers
30 views

How to check if the OpenSSL version is -ge 1.1.1 in a shell script?

My script requires OpenSSL 1.1.1 or newer for it to function. Of course, the first steps are to get if OpenSSL is installed on that system, and if yes, then get the version of the default OpenSSL ...
0
votes
3answers
49 views

Comparing 2 base filenames in separate directories in bash script

I am trying to write a bash script that takes 2 file directories as arguments. It then loops through all the files in the first directory to see if there is a corresponding file in the second ...
0
votes
1answer
34 views

Interactive bash script: Prefix all lines with a string

I want to create an interactive CLI in bash. Similar to the way bash prefixes every line with user@host:~$, I would like to prefix every line with foobar>. This functionality can be seen in CLI ...
0
votes
0answers
21 views

Controling the order of variable expansion in Bash [duplicate]

I have a question. If foo1='bar' foo2='baz' num='1' and I want to do something like this: $foo$num $foo1 bar where $num expands first and $foo1 (as a result of $foo$num) is expanded. How would I ...
0
votes
1answer
29 views

Script with zip command doesn't work with wildcards

I created a bash shell script to zip all files that match a pattern as follows: #!/bin/bash zip $1 $2 When I run the above script using ./myScript.sh myzip test*, only one file that starts with the ...
-3
votes
0answers
49 views

Can someone explain what this command does in Linux in detail?

$PMRootDir/Script/GetFiles $PMRootDir/$$LOCALDIR $$FILESERVER/$$FILENAME.$$EXT > $PMRootDir/TgtFiles/$$GETFILELOG 2>&1
1
vote
1answer
32 views

linux shell script that allows you to launch and stop an application

(Editors note: Google-translated text follows) Hello to you. I would like to create a shell script that allows launching or stopping an application. The shell script will take a start or stop ...
0
votes
1answer
33 views

Variable defined in current file and echo an external file into it, which calls the variable

On my Linux machine - I do the following: Create a script named script.sh #!/bin/bash variable=`df -hP` echo < my_file.txt Then I create an external file called my_file.txt The disk ...
0
votes
2answers
38 views

$STRING1 != “${STRING1/substr/}” in Linux

I have one string and I want to check if it contains the sub-string or not. So I am using this command. Below is the Linux shell script. I just want to know how the condition present in if statement ...
0
votes
2answers
30 views

how do I get my code to use the value of the $HOME variable?

I'm trying to put together a generic script that will check the existence of several key directories for various users on different servers. Additionally, I want to leverage each user's $HOME variable....
-2
votes
0answers
17 views

Shell script to find the string in the XML1 file between tags and raplace from another XML2 file

The XML1 file has several ... tags. I need a script to find the string "thing03" in the XML file between the beginning of the tag and closing the tag and replace it only with the string "thing03" ...
0
votes
1answer
15 views

Run a simple script during sleep/suspend

How can I have a simple bash script run during sleep? The script is pinging a machine on the network every 5 seconds, and if it is online, it will wake the computer from sleep. Is this possible on ...
2
votes
3answers
153 views

How to find words that follow a specific order

I am trying to write a script(script1.sh) that finds every possible word when given a jumble of letters. The words must start with the first letter of the jumble and end with the last letter. The ...
0
votes
1answer
18 views

Escape variables to go into script

In Bash, I've been trying to get the following content into a file: for pid in $(ps -lef | grep ssh | grep 2048 | awk '{print $4}'); do kill -9 $pid; done Doesn't matter how I try to put it, in, say,...
1
vote
0answers
13 views

Send mouseclicks at coordinates

I am currently utilizing a script to send mouse input to certain buttons like this: xdotool mousemove <x> <y> xdotool click --window <window_id> This works fine, but it is annoying ...
0
votes
2answers
63 views

How to get a random adjective or noun?

I did find a list of words in /usr/share/dict/words but I don't know if there's a way (an already existing way?) to split them up into their corresponding part of speech? Alternatively, I'm fine with ...
7
votes
9answers
1k views

How can I evaluate a math equation, one per line in a file?

I have a file with the following: 37 * 60 + 55.52 34 * 60 + 51.75 36 * 60 + 2.88 36 * 60 + 14.94 36 * 60 + 18.82 36 * 60 + 8.37 37 * 60 + 48.71 36 * 60 + 34.17 37 * 60 + 42.52 37 * 60 + 51.55 35 * 60 ...
0
votes
4answers
68 views

awk - extract value infront of “somestring:”

I'm creating a script that will get the UUID of inserted drive realtime using udiskctl monitor these are some of stdout lines HintPartitionable: true HintSymbolicIconName: ...
0
votes
1answer
65 views

When using variable in sed it replaces entire line, instead of just the matching string

I'm new to bash and I've been trying to understand other posts that's similar, but I'm just not sure if they do the thing I need. When I don't use variables and just put in what I want to search for ...
2
votes
1answer
27 views

Create Xen guest with preinstalled packages and settings

For context, I'm creating a script to simplify the process of creating xen guests. The script uses xen-create-image and uses a bunch of flags to set as many useful settings as possible (distro, vg, ...
1
vote
1answer
40 views

How to pipe git log to curl command

My goal is to perform a curl with the output of a command as curl payload, separately they work, but i have not been able to merge both things into one. This is my first command, it prints the ...
0
votes
3answers
56 views

Bash script convert

i need to convert the text below in bash script 111319 2036 to 11/13/19 20:36 it's possible? regards.
11
votes
5answers
2k views

“Store” a remote SSH session?

I am trying to do these in a script. I have to run some commands on a remote host. Currently, I am doing this: ssh root@host 'bash -s' < command1 ssh root@host 'bash -s' < command2 ssh root@...
1
vote
1answer
46 views

How to run multiple scripts one after another but only after previous one got completed?

I have to run several python scripts one after another but want to make sure previous one got completed. How can I do that in Linux? Can it be done by simply using && or ; or | ?
1
vote
2answers
53 views

Generate a color code from an arbitrary string

I want my shell prompt to have a different, unique, consistent color automatically based on the hostname of the server. For example, when I log in to a particular server, the prompt should be a ...
0
votes
0answers
27 views

Find Command Works from STDIN but not within a script

#!/bin/bash dt=$(date '+%m-%d-%Y_%H:%M:%S') logpath="/home/foobar/system_backup/backup.log" topfile=$(head -n1 "$logpath") echo "$dt" >> "$logpath" echo "Please enter a name for the log ...
0
votes
3answers
43 views

How to get the serial number of the pen drive in bash

cat /proc/scsi/usb-storage/27 ------------------ Host scsi27: usb-storage Vendor: SanDisk Product: Cruzer Blade Serial Number: 4C530000230331109030 Protocol: Transparent SCSI ...
0
votes
1answer
24 views

Script to remove all modules in pom.xml except the one with the highest number

Question I have a huge pom.xml from a Talend DI/ESB project, where it was possible to have multiple lines for the same module with different Talend specific versions (don't even ask for that :-( ) ...
0
votes
1answer
35 views

Curl command in bash CGI script not displaying the XML output [data not shown]

if I run this command in linux shell. curl=`curl --connect-timeout 4 -k -X POST -H "Content-type: text/xml" --data "<MyRequest><HeartBeat timestamp=\"1311157780201\"></HeartBeat><...
8
votes
10answers
1k views

Bash script that shows changing real time values from commands

On a Linux machine I have a series of commands that offer numerical values of the state of different sensors. The call of these commands is something similar to the following: $ command1 5647 $ ...
0
votes
0answers
33 views

executing underscore commands from a shell script

I'm trying to write a script that would (among other things) change the base16 color theme. I can do it from the interactive shell writing base16_{theme}. Turns out this command is an alias to _base16 ...
0
votes
2answers
35 views

Bash glob expanding to multiple arguments

I am new to bash scripting. I've got a script to ping multiple machines that "I" wrote : for var in "$@" do ping -c 1 -W 2 "$var" > /dev/null echo $var = $? done What I'd like to ...
0
votes
1answer
32 views

Need to copy file from one path to another path

need to copy file form one path A to another path B and then want to delete the original file form path A .with Linux script
1
vote
0answers
29 views

If I know the corresponding encoded bytes to some characters, how can I determine matching charsets?

I have a few files where the filenames obviously use the wrong charset. As soon as I know which charset is being used, I can use convmv to convert it to UTF-8. From the rest of the filename, I can ...
1
vote
0answers
21 views

BSD netcat how to terminate after sending command?

echo "test" | nc -N -U example.soc How can I have this terminate once it has successfully sent the message over? According to the man page: There should now be a connection between the ports. ...
2
votes
0answers
29 views

Backup Script with Lock giving Invalid Syntax Error

I'm setting up a simple backup script to backup key files on my server every 12 hours. Just trying to test the script now and I'm getting the following error message; python /<pathwayhere>/...
0
votes
0answers
24 views

Konsole --new-tab: choose which existing konsole instance

I usually have several konsole windows on several desktops. Running konsole --new-tab is intended to open a new tab in an existing window, but it seems never goes to the window I want. This is really ...
0
votes
1answer
47 views

script to move files to Google Drive

I have a CentOS 7 server, no desktop gui. It's used for inbound/outbound VOIP call recording, my plan is to copy today's recordings to my Google Drive. I have seen multiple Google Drive Linux ...
0
votes
5answers
68 views

Bash: Split a variable after the first occurence of an alphabetical character

I have a variable which contains a line from a crontab eg: 0 22 * * 1-5 echo hello I want to split this into 2 variables, one with the numbers or asterisks denoting the periodicity of the job, and ...
0
votes
1answer
29 views

Placing File Families into Folders

A large number of font files (2728 files) are flattened in to a single folder. I want to move all files belonging to the same font family into a folder where the folder name is the complete name of ...
0
votes
1answer
28 views

Syntax error in script for chacking date of file modification

So I wanted to make a script in shell that when executed, either modifies a file or echoes back a message. Here is what I managed to write: #!/bin/bash current=$(date +%s) last_modified='stat -c "Y"...
-4
votes
1answer
45 views

Script that makes directories from A to Z and files in them from 1 to 9 [closed]

Do you have any idea how would a script in shell would look like with the following conditions: When executed, it has to make Folderz from A to Z In every folder, it has to make blank file from 0-9 ...
-1
votes
1answer
50 views

How may I change permissions on files that starts with digits?

I want to change permission on files that starts with the digits 1 through to 9 (e.g. 1.txt, 2.txt etc.) My code looks like this: #!/bin/bash for(( i = 1 ; i < 10; i++)) do for file in /...
0
votes
0answers
21 views

Copy files from a company share to public dropbox using rsync or find, etc

I am working to get a data transfer service up to which I can copy only newly created files in /h/data/share/(company share) to /g/data/global/ (public dropbox), however the files in /g/data/global ...
0
votes
1answer
42 views

How can I display the largest common part of two files?

I know how to use comm, diff or grep to display every common line of two files. But how can I display only the largest common part, i. e. the most common lines in succession? (If there are equally ...
0
votes
1answer
41 views

Can I use `diff` to display not the different but the matching parts?

man diff says: diff - compare files line by line So diff will compare the files. However, eventually, it will show the difference, if there is any. How can I compare the files and show the ...
1
vote
1answer
44 views

Copying/Moving folders where destination folder already exists

I am writing a bash script to copy/move a folder called "folder" to a directory that already contains "folder" and I would like the contents to be merged. I am attempting to use a solution from this ...
4
votes
2answers
57 views

Run udev script every minute (displaying Dualshock 4 Battery level)

I created a simple script that changes the Dualshock 4 Gamecontroller LED color bar based on its Battery status (using the answer https://gaming.stackexchange.com/questions/336934/how-to-set-default-...
0
votes
2answers
44 views

Piping Output of Shuf Command [duplicate]

Fairly new to Linux. I have a nixie clock that runs off of a Raspberry Pi. I would like to send a random sequence of six digits to it every so often to help prolong the life of the Nixie tubes. ...
0
votes
3answers
54 views

Move files with date in file name to directories

Need help sorting files by date within name with a script I can set in my cronjobs. The string I am trying to extract and make directories is the YYYYMMDDHHMMSS, this is present in all file names. # ...