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.
4,499
questions
-1
votes
0
answers
23
views
What's the difference between "ps > log" and "log < ps" in GNU Bash shell? [duplicate]
Why is that in the command "log > ps" the shell considers "ps" as a file?
Does these operators (> and <) behave differently in other shells aside GNU Bash?
-1
votes
0
answers
21
views
Why "read var 1< file1" does not read from file in GNU Bash shell? And why "read var < file1" does? [duplicate]
If the number 1 means stdout, why I'm not reading the stdout from file in "1< file" ?
0
votes
1
answer
31
views
What is wrong with this if statement script comparing variable against a number range
I have made a script with if to check for a running timer, but the script sometimes accepts the check and the other time it does not. I do not know why ?
The timer is read and set into a variable, it ...
0
votes
1
answer
32
views
Linux Shell Script replace last shown lines at the screen, not write it under the last once
i run a script from bring formated numbers to the screen :
#!/bin/sh
while true ; do
echo
awk -v x=987654321 -v n=8 'BEGIN{srand(); while (--n) {$++NF = int(rand() * x / n); x -= $NF}; $++NF =...
0
votes
1
answer
49
views
join a specific number of files/devices in linear mode together in a linux system
For joining in Linux files/devices in linear mode together i have this script dm-joinlinear.sh from
join files/devices in linear mode together in a linux system , thanks telcoM
#!/bin/sh
usage() {
...
0
votes
1
answer
47
views
Use fallocate with numbers from text file
For testing i create at my Linux-System the file list.txt. In there are numbers like:
4 1 5 2 3
(sometime there are more or less numbers)
How do i run these numbers with fallocate?
fallocate -l ...
-2
votes
1
answer
108
views
Linux Bash Script - Yes or No - read answer
little script
#!/bin/sh
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 24 | head -n 4
printf 'do you like this? (y/n)? '
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
...
1
vote
3
answers
38
views
Bash: Access variable with another variable [duplicate]
How can I access a variable with another variable, like this?
varAble="Hello"
varA="\n"
varBable="World"
varB="END"
for part in A, B
do
echo var${part}ble
...
0
votes
2
answers
22
views
How do I update the contents of a script including comments (django/settings.py) using echo, printf or grep
I would like to overwrite a Django/app/settings.py text file using the Linux terminal command printf.
The settings.py starts with docstrings comments, i.e. """some text"""...
0
votes
0
answers
25
views
SLURM job script - why is the tmp local directory deleted before archiving can occur? How to prevent this?
I wrote a SLURM job script to run a computational chemistry calculation using the CREST program (part of the xtb software package). In the script, I create a temporary directory on the local storage ...
0
votes
2
answers
98
views
How to write an alias or bash script that renames a single file using the same syntax as the `ren` command of Windows?
I am a long-term a Windows user, so I find the syntax of the ren command both simple and convenient:
ren C:\pathTo\myFile\oldFileName.txt newFileName.txt
[Update 24 July 2024] To be clear about my ...
-4
votes
3
answers
94
views
show which of a list of filenames do not exist in a given list of directories
I have a long list of filenames like 20231121_150111.jpg... in a text file (one filename per line).
And another list of directories. Those directories contain files.
How can I check and show which ...
1
vote
0
answers
27
views
Running a program/script before a user logs in on RedHat Linux GUI
I am looking to run a script prior to a user being able to log in on the GUI.
Its a basic script, do you accept Ts&Cs Y/N, enter user name, data is captured and stored. Then once complete takes ...
5
votes
5
answers
767
views
how to format a text file in bash with dots from right
I have a file on a Linux system with various numbers, all on a single line (numbers_in_one_line.txt):
1941102556 1750145810 2604905 7000793682 5160065824 3000350768 6449300295 3046118928 12693055728 ...
-3
votes
1
answer
104
views
How to split a number into unequal parts in Bash
Hypothetic example: There is a number that I will split into x parts (smaller numbers, in a range you see in the example).
I need a way, ideally a one liner for the Linux Bash, to split a large number ...