Questions tagged [shell-script]
A shell script is a script written for the shell, or command line interpreter, of an operating system.
1,441
questions
0
votes
1
answer
116
views
How to convert code from test format to if fi format?
I have code that opens a bash file in a terminal for entering the sudo password:
test "$IN_TERM" || {
export IN_TERM=1
konsole -e "$0"
exit 0
} && true
I need ...
-1
votes
0
answers
36
views
How to write a script in MobaXterm [closed]
I have never really done any coding before except for an introductory class to Python for school. I need to know how to write a script in MobaXterm that will essentially shell into another machine(s) ...
2
votes
0
answers
61
views
Is there a good way to write a shell script compatible with both bash and zsh that addresses array elements?
The fact that bash is 0-indexed and zsh is 1-indexed can cause problems. For example the following will work as intended with bash, but not zsh (PS I am aware that I don't NEED to use an array for ...
-2
votes
0
answers
13
views
automation idea for jdk upgarde in different servers
Need to upgarde the all jdk versions in all oem agets installed servers, currently we are using manual process by login in to each server and running the commands. need an automation idea, we are ...
0
votes
0
answers
14
views
Install a shell script with homebrew -- to install darktable (1_install_hb_dependencies.sh)
I want to build darktable from source w/ homebrew, like so: doc on Github. I have installed homebrew (step 0). Now I'm stuck at the first step where I need to install ''required homebrew packages'', i....
0
votes
0
answers
153
views
Termux can't run shell script
As stated in the topic above, I am trying to configure a hardware using shell script which is downloaded from the official website of Orange Pi. Am using termux as the medium to run the shell script ...
0
votes
1
answer
49
views
Having disabled command-Q for Terminal via shell defaults command, how can I re-enable it?
I have a large, complex console program for execution via Terminal which solicits many responses from the user. Users may be habituated to use command-q to exit a program. This program has its own ...
0
votes
0
answers
45
views
ffplay works from command line but error with .sh script and systemd
(Originally posted as a generic question, then I found the ffplay forum)
I'm trying to set up a daemon to play short sound effects as part of an interactive wheelchair ride. (Due for installation next ...
0
votes
1
answer
69
views
How deep is too deep for Nested Folders in a Bash program?
I am somewhat new to Bash and am writing a program to install .NET SDK and Runtime on each of the available Linux distros.
The problem I am having is that I am trying to source functions from two ...
0
votes
1
answer
60
views
zsh on MacOS catalina 10.15.17
I'm having a little trouble putting this all together...
I want to make a simple shell script to organize and sort around 60 GB worth of music and movie files that are spread out over 3 or for 4 ...
1
vote
0
answers
65
views
Source multiple files in background/parallel (ZSH)
For various reasons I would like to be able to source a series of files in background and wait for them all to finish:
source ./my_file_1.sh &
source ./my_file_2.sh &
...
# etc
wait
But, ...
0
votes
0
answers
52
views
lftp in shell script fails with "pseudo-tty allocation failed" only when run via cronjob
I am trying to create a shell script which copies a file to a foreign server using SFTP (because SSH is not available on the foreign server). The script works as expected when run via console, but it ...
0
votes
0
answers
28
views
Programmatically open new CMD and enter code *but not run it*? [duplicate]
Is it possible in Windows to programmatically launch a new instance of CMD, Terminal, or PS (doesn't matter which) and populate the input field with some arbitrary code, just like if a user was typing ...
0
votes
0
answers
59
views
Perform lookup on two files
I have a csv file that get's SFTP'd to a RHEL box I have setup. It then gets transformed a little before another process SFTP's in and grabs it sending it off to be imported to a DB of a 3rd party.
I ...
2
votes
1
answer
56
views
Query effective ssh (client) config from the command line
Is there any way to query the effective ssh (client) configuration?
Specifically: can I determine e.g. whether there's an entry for a given host, what's the ProxyJump or User setting for that host etc....
0
votes
1
answer
60
views
Complex find statement
Have a script that I use to purge old backup directories. All the directories are named YYYY-MM-DD. The backup directories have links in them as the backups are incremental using the rsync --link-dest....
3
votes
1
answer
41
views
Is it possible to schedule "Alarms Only" mode in Windows 10 using a shell script?
I want to automate this to trigger every day at certain intervals, it seems so hard to configure a good notification system in Windows 10.
I would like to trigger the Windows focus "Alarms only&...
1
vote
1
answer
146
views
Maintain a fixed-size-queue of nohup jobs
Suppose I would like to run multiple nohup jobs but at each time I would like to at most run 4 nohup jobs.
Is there a way to:
keep track of 4 nohup job status
once one of them finishes, it triggers ...
2
votes
1
answer
71
views
Algorithm to find longest common substring
I'm having a bit of trouble coming up with a general solution to the following problem.
First a bit of context.
End goal: set file permissions on all files and directories created by a rpm
My plan was ...
0
votes
0
answers
383
views
Reference shell Script within a shell Script in YAML
Is there the right way to reference a shell script written within a script in a YAML file. For eg:
data:
ex1.sh: |
#!/bin/bash -x
. /shellscriptloc/ex2.sh
...
...
2
votes
0
answers
37
views
SFTP user login details real-time filtering
I have enabled the SFTP login log into the default logfile /var/log/syslog and tried to filter the login time of each user and insert it into the database.
But the filtering is not worked as I ...
0
votes
2
answers
120
views
Bash printf: what does format specifier %P mean?
The printf statement :
find directory1 -type d -printf "%P\n" | sort > file1
in the answer https://superuser.com/a/166322/856910 includes a format specifier %P. From the output of this ...
0
votes
0
answers
218
views
how to print an entire get request from an API in Powershell?
I am working on a powershell script that displays all of the dns servers I manage via GoDaddy, and see which ones are about to expire. I am using the GoDaddy API and this following code:
. .\configs\...
0
votes
0
answers
15
views
How can I read input directly from the terminal instead of stdin [duplicate]
TLDR; I want to read a user input directly from the terminal leaving stdin untouched.
context
I'm writing a shell script that handles user passwords (verifying strength and authenticating other apps).
...
0
votes
1
answer
228
views
Running shell Script via Systemd.timer
So I've essentially run into the same problem as in my other question: Running shell Script via Crontab
I will now run my shell script with systemd.timer but it is not working so far.
Here is my ...
1
vote
2
answers
140
views
How do I run a bash script automatically everytime I hit CTRL + S?
I'm making frequent changes to a bash script and everytime doing "./demo_script.sh" is repetitive.
Is there any way that it can automatically execute as soon as I hit CTRL+ S on keyboard?
2
votes
2
answers
86
views
Why the variable doesn't change even if it should?
I have this bash script:
#!/bin/bash
someVar=0
tac /etc/hosts | while IFS= read line; do
echo "$someVar : $line"
someVar=$((someVar+1))
done
echo "Finally: $someVar"
...
-1
votes
1
answer
327
views
I would Like to know what -sb and awk '{print $1}' role in this command
subdirectory_size=$(du -sb "$entry" | awk '{print $1}').
I would Like to know what -sb and awk '{print $1}' role in this command.
1
vote
1
answer
645
views
Change the default location of zsh completion cache files for macOS
I'm trying to change the default location of the zsh completion cache files in macOS. I have read the zsh documentation on completion which say's "alternatively, an explicit file name can be ...
0
votes
0
answers
75
views
How to automate mybb installation using ssh bash script
I have created this bash script to install mybb application automatically on Centos stream 8.
SSH Bash script
#!/bin/bash
# Define variables for MyBB installation
DB_NAME=mybb_db
DB_USER=mybb_user
...
2
votes
2
answers
98
views
What options are being used by sed to parse a file and write to new file
I am debugging a LINUX script that was written by someone else. In the script we have a line of code like below
sed -i "\#</resources>#{h;s#.*#cat /opt/abc/new.xml#e;G}" /opt/abc/...
1
vote
1
answer
164
views
Can't input text in Bash function called with key binding
I have added a simple function to my .bashrc file and bound it to a key combination using the bind command. The function prompts the user for input using read, like this:
myscript() {
read -p &...
1
vote
1
answer
141
views
Batch rename movie folder(s) to movie file inside of folder?
I would like to rename my movie folder names to match the movie file name inside the movie folder. The movie files have the right names but the folders do not.
I've found batch file rename options for ...
1
vote
2
answers
405
views
Batch processing stdin lines with Windows batch .bat script
I have a Windows batch script delete.bat with that contents:
@echo off
takeown.exe /A /R /F %1
icacls %1 /grant Administrators:(OI)(CI)F /C /T /Q /L
rmdir /S /Q %1
echo %cd%\%1 >> "C:\...
0
votes
0
answers
168
views
Sftp credentials working in winscp but not in command line
I have a windows server which I also log into via putty. On the windows server, i have winscp with saved and working logins. From winscp > Generate Session URL, I can get a specific accounts login ...
0
votes
1
answer
44
views
How to highlight text using color in output if in a certain temp range
I am outputting the HDD temps of my system to a text file on a local webserver that I can check every once in a while to monitor hdd temps when the system is under load. I was wondering if there is a ...
-1
votes
1
answer
285
views
Confused on how to use mkdir with shellscript
I'm trying to create a program that recursively makes folders for fun and I'm having trouble using mkdir. When running it in terminal it gives back these error messages:
./folder.sh: line 6: syntax ...
0
votes
1
answer
237
views
Powershell: sorting directories based on file count
I am attempting to create a list that counts the number of files in a folder and then sorts the order of the folders based on that count. I have the following but it doesn't work (i.e. doesn't sort):
...
1
vote
1
answer
854
views
How to execute "source" command inside a shell script and then store the output of source in a variable within the shell script?
I have written a shell script (called profile.sh) to fetch temperature values from the Android MPSoC. Separately, I have found a shell script that fetches the FPS of an app on the Android system as ...
0
votes
1
answer
111
views
Script to add a tag at the end of files in a folder in case that tag is missing
I'm struggling with a shell script. I have a bunch of xml files, more than 500, and some of them has no end tag </deliveries> I created a shell script that works but only if I write the filename ...
0
votes
1
answer
73
views
Geany – display file path line
I’m a new Geany user. I code shell scripts on Linux.
How to display "files path line" like this Geany image below ?
I can't find any options in the Geany settings.
Do I need to install a ...
-1
votes
1
answer
128
views
Powershell infinite loop and returning unexpected results
Script
PS C:\folder>$a=@(100,001,10,101,002,11)
$arrayCount=$a.count
for ($i=0; $i -le $arrayCount; $i+=3) {
$oldNumber=$a[$i]
$oldNumber="{0:d3}" -f $oldNumber
$newNumber=$...
0
votes
1
answer
2k
views
Is it possible to remove cURL command?
I am a new Tier2, Tier3 is requesting I attempt to write a script to remove the curl command from student PC's, is this possible? Should I suggest disabling curl via AD group policy?
0
votes
1
answer
264
views
How to find the "pattern" in FASTA file and record the cordinates along with header
I am looking for a solution to search for a string of 17 base pairs in the FASTA file that is the human reference genome.
To clarify, in simple words and put the resources, i have tried grep function ...
0
votes
2
answers
104
views
Using sh with bash
I am using ubuntu OS and my default shell is the bash. However, still I can use the Bourne shell ( sh) for writing the shell scripts, through including :
# !/bin/sh
How can I still use sh although I ...
-1
votes
1
answer
125
views
I want to find one user using regex from the text file which is in json like format. Find the user with regex and remove it with surrounding text
Find the user from the below text (highlighted testUser)
define name{
name **testUser**
aliasName Test User
emailID ...
0
votes
1
answer
474
views
How to stop output separated by blank lines with xmllint
I have the following xml generated from Gnote:
<?xml version="1.0"?>
<note version="0.3" xmlns:link="http://beatniksoftware.com/tomboy/link" xmlns:size="...
1
vote
0
answers
134
views
ssh.localhost.run tunnel configuration command on Shell
I am currently writing a shell script for automating.
Manually, I will create a new session ssh.localhost.run by input Tunnel information on PuTTY like this
Full steps:
host name "ssh.localhost....
0
votes
2
answers
114
views
How to group a flat list into categories and create a tab-separated value file using awk?
Crosspost: https://www.nixcraft.com/t/converting-a-list-into-a-tab-separated-file-grouped-by-values/4517
I have a text file with a list of values. The goal is to create a tab separated values file, ...
1
vote
1
answer
742
views
How to add lines above and below a certain line in Powershell based on regex pattern?
03,201779,,01354,73923309,,,TEST2,7962753,,,0343,5087632,,/#end of line
04,399,777873,,,,text234,,,,/
33,TEST1,,,0343,,93493,,,343,,,,TEST3,,,,,,/
37,TEST37,text
49,24605597,6,343,343,343,,,3434,,,/
...