Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.).
-3
votes
0answers
22 views
If else statement on shell scripting [on hold]
I want to make a script using if else statement. Example, if the first script abc.sh has successfully executed then it should run the second script def.sh It should 5 minutes after i ran the first ...
2
votes
2answers
36 views
Bash script is not terminated with Ctrl+C
My script cannot be terminated with Ctrl+C key. It is an error.
Please explain how to modify my script to make it terminable by Ctrl+C.
#!/bin/bash
while true; do
paplay ...
0
votes
3answers
56 views
What is the most concise script to list the missing ones in a digit sequence? [duplicate]
For example, we have the content
001
002
004
008
010
in a text file named file, how to extract the missing 3 5 6 7 9?
0
votes
1answer
13 views
xterm no absolute path found for shell
I am trying to run a script in SUSE Linux Enterprise 12 from java using ProcessBuilder. Codes for this follows:
ProcessBuilder pb = new ProcessBuilder("xterm", "-e", "script_path");
Process pr = ...
1
vote
1answer
22 views
Using special character " and ` in send command in expect script
I am trying to execute a command in Linux servers to fetch which all servers requires root password reset as there are multiple servers I am using an expect script to automate it , my command contains ...
-1
votes
0answers
19 views
How can I get a script to run in a menu selection? [on hold]
In vi editor what is the command that you would use to get a script to run when the option is selected?
0
votes
0answers
21 views
script to change an option and show it in a selection
I need option 2 to display Run myscript
when you select option 2 I want it to run my script
can anyone help me
3
votes
3answers
75 views
Bash: Convert a string (version number) to an integer
I want to get the version of glibc and use it in an if statement stating if glibc is less than 2.15 then.
However the issue is that when using the ldd --version this is output as a string. i need to ...
1
vote
1answer
28 views
Is there a way to resolve ALL PIA VPN IPs with a script?
I am looking for a way to get a complete list of all the current IP addresses for PrivateInternetAccess' servers. I need the complete list so that I can manually enter them into a killswitch for ...
2
votes
0answers
11 views
Using a web browser to generate a gallery/slideshow from local files
I'm trying to see how far I can go with using a web browser for various tasks vs. native apps. One of these tasks is selecting a group of local image files and generate a preview/gallery/slideshow in ...
1
vote
1answer
40 views
Why don't the SHA's match?
I am trying to write a script and it uses the SHA of a date but I am getting two different results and for the life of me can't figure out why.
echo -n 03112016 | cut -d'.' -f4 | sha256sum | cut -d' ...
1
vote
2answers
59 views
Rename files in a directory
I have the files names as below in a directory
example1.1.timestamp(.1457644337)
example1.2.timestamp
example1.3.timestamp
and so on about 100 files. I need to rename all the files by removing the ...
1
vote
0answers
28 views
Assigning floating point value to array in Unix shell script loop [on hold]
I am using ksh scripting on Ubuntu 14.04 and am trying to write a script to add floating point numbers to an array. My code is as follows
numLoops=6
numerator=14996288
denominator=1000000000
for i ...
-1
votes
3answers
49 views
Shell scripting : want to login on some server, which are in same domain and execute command and exit
I have 10 unix servers, I want to log into them one by one, execute 4-5 lines of code, save the output and exit.
For Example: 10 serves:
Intially at xyz server
Login in server 1 --> execute 4-5 ...
1
vote
1answer
57 views
What do \t and \a mean in a shell script?
What do \t and \a perform or do in a script? For example, I am writing a script and it goes like this \t it displays a simple script \a
1
vote
2answers
36 views
getting the owner of the folder with the if command
i want to be able to prevent people from accidentally deleting critical files of the system in my my script, does anyone know how to use the statement to find if the owner of the folder?
0
votes
1answer
219 views
Is the xkcd universal install script a good idea? [on hold]
Today XKCD posted this shell script:
Alt-text:
The failures usually don't hurt anything, and if it installs several versions, it increases the chance that one of them is right. (Note: The 'yes' ...
1
vote
2answers
53 views
make a shell script to be run as a second user
I am making a script where I wish to run two services as a certain user. The script should switch to a user and then run a program and after the program has been executed, it should start running the ...
-1
votes
2answers
31 views
bash better way to parse string?
I need to parse below command to extract namespace & intf names using bash script, I generally do this using IFS, but that seems tedious to me
is thr a better way of doing this without setting IFS ...
3
votes
3answers
55 views
How can I remove just the writable files in a directory, without any prompt?
I want to delete only the writable files in a directory. If I do
rm *
it removes all the writable files (so far so good), but I get a prompt for each non-writable file. I don't want a prompt, I ...
0
votes
2answers
39 views
Can I have a (bash) shell with expect running in the background?
I am trying to write an expect script that once started will watch my terminal and run a command every time that it finds a match.
Is this even possible with expect? If so, would expect_background ...
1
vote
4answers
51 views
move a file that matches a pattern in a shell script
I have very little experience in writing shell scripts and need advice on how I can accomplish the following task.
I need to move the most recent file in a directory where the filename matches a ...
3
votes
1answer
100 views
Delete lines from a file
I have a file where data is present in below format :
cat file.txt
02|123
04|321
08|453
09|364
01|789
23|765
so here 02,04 ... represents Hour and 123,321 ... represents some random value.
I want ...
0
votes
0answers
23 views
How I compare multiple file results and then using its file result execute the next command?
I run a sql script through atable to insert data from one T1 to T2 (total 8 tables). I am doing row counting between two tables if counts match then it returns 1 else 0 and stored result ('1' or '0') ...
0
votes
2answers
23 views
shell scripts when exceeding 100 seconds to send an email
When executing show engine innodb status on mysql, there are lines like ---TRANSACTION 17610C9A, ACTIVE 504 sec starting index read.
I need a script to monitor for when the number of seconds after ...
1
vote
4answers
42 views
Remove any occurrence of '-' from a field in shell script
below is my csv file,I want to remove all occurrences of - from retailer_id field and create new csv. Kindly help...
...
0
votes
1answer
26 views
command line in su - and background
I am writing a simple unix script to automate reading of a log file.
The following does not give any output to the terminal. It just asks for the password for buser and then it just hangs. I ...
0
votes
2answers
39 views
Compare a file with a column of another file
I have a file File1 with data as
aaa
bbb
And another file File2 with data as:
2,aaa,234
w,bbb,589
4,ccc,675
I need to compare the File1 data with column2 data of File2 and print the matching ...
3
votes
1answer
59 views
VAR=`cat file` and then repeating echo “$VAR” is slower than repeating cat file. Why?
There are about 10.000 files in files/ and 10.000 lines in metadata.csv.
Where metadata.csv contains information about the files.
I have a shell script which prints information about each file and ...
1
vote
2answers
61 views
How to repeat prompt to user in a shell script?
In a set of if/elif/else/fi statements, I have made 'else' present the user with an error message, but I also want it to take the user back to the question which was asked before the if/else ...
0
votes
1answer
27 views
Impossible to write files with root credentials
I'm trying to launch a small script which fixes a bug in iceweasel icons.
Here is the script. You can find it as a workaround in the bug report
for n in 16 32 48; do inkscape -z -w $n -h $n -e
...
0
votes
2answers
59 views
How to use cd command in su command?
In the below script the cases aserver and bserver work fine. But in case "cserver" above, after su - gsxuserp, I need to perform the following three options with the same user.
cd ..
cd ...
2
votes
2answers
65 views
Sorting ls output where files end in numbers [duplicate]
Here is the output of my normal ls command:
f1 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 f2 f20 f3 f4 f5 f6 f7 f8 f9
So I have 20 files. I need them displayed as :
f1 f2 f3 f4 ...
0
votes
0answers
17 views
the md5sum command cant find my archive [on hold]
I was testing a backup script and when the script attempt to make md5sums for the archive, it keeps saying "File Not Found" while the archive exist and I checked the spelling. Can anyone help, here is ...
1
vote
1answer
50 views
Sed command usage without defining variables in shell script
I have two variables
source_repo="fdl_ppe_01_04_repos_svc"
target_repo="fdl_ppe_01_10_repos_svc"
and I currently do a substitution within an XML file to replace all instances of $source_repo with ...
1
vote
3answers
41 views
Return an exit code without killing caller's terminal?
I'm having a hard time getting the return value from a script. The script that is giving me trouble is second.sh below. But there's an interaction present with a script called first.sh, and that ...
0
votes
1answer
34 views
Trouble with Screen Rotation Script
I am running Antergos linux with Gnome 3.18.2 on a Dell XPS 12 Convertible laptop/tablet, and am working on making the screen rotation more convenient.
I pulled a version of the following script from ...
1
vote
2answers
38 views
set -u usage not working as expected
I am learning how to efficiently use different set options in my script and came across set -u that appears to be perfect for exiting my script if a variable does not get set properly (ex. deleting ...
0
votes
0answers
28 views
Fractional time with the `at` command [closed]
Is there any way to use the extremely useful at command with a fractional amount of relative time? I'd like something to be done, say at now + 1.5 hours, but that's not working for me. I also tried ...
-2
votes
0answers
16 views
Looking for a way to perform several actions with scp
I'm trying to get some data from another machine onto my own machine. Specifically, a list of files. I don't, however, want all of the files to be copied; only the ones with the suffix ".gz". Then ...
0
votes
1answer
59 views
-r filename && . filename
i was just looking into a script i find this line. can anyone tell me what this line do. this is the code line.
[ -r "$PosConfigDir/posconfig.sh" ] && . "$PosConfigDir/posconfig.sh"
0
votes
1answer
34 views
Extract a specific part of the path of a file
Taking this path to a file: words/05_díj/díj_pct.txt how I can extract only this part? 05
What I want is to use that part as a value for an external variable for the execution of an awk script.
...
0
votes
1answer
53 views
Parse numbers with delimiter - BASH
I would like to parse ports, for instance 45:68. I defined testing var.
echo "ports"
read in
I splited ports to array:
IFS=":" read -ra port <<< "$in"
Ports must be less than 65535, ...
0
votes
1answer
39 views
Verifying output of a command not quite working via BASH script
In attempting to verify if a remote database exists or not, I'm seeing mixed behavior with a conditional statement.
Technically the statement is working (it correctly reports if database is found), ...
-1
votes
0answers
16 views
TSM Backup server script to perform a presched cmd and post sched cmd by checking backup status [on hold]
We have 1 Front end server which has a .cmd script when it runs it suspends the sql server db which is on other system and sql db is integrated with nas shares,
The setup need to be backup when the ...
4
votes
1answer
95 views
Launch a sudoed command upon script termination?
I'm coding a bash script that:
runs some sudoed command at initialization
releases root permissions for security purposes (sudo -K)
runs an unprivilegied program
but needs root permissions when ...
1
vote
1answer
54 views
Untar File.tar.gz from Shell w/Nested .tar
I am trying to untar a file from a shell script. There is one file within the file.tar.gz that is a tar that is not getting untared.
I have tried several methods with no luck.
...
0
votes
1answer
21 views
Make exported path effective immediately?
I'm using a script to export a path like this:
echo "export MONO_PATH=~/turbo/" >> ~/.profile;
So from now on, the path will be available whenever the user logs in. However, I want to the ...
-1
votes
3answers
64 views
How to catch with RegExp first word with different first symbol in it using ed text editor
I have shell command:
printf '/^PermitRootLogin/\nc\nPermitRootLogin no\n.\nw\nq\n' | ed -s /etc/ssh/sshd_config
And I need catch #PermitRootLogin like PermitRootLogin but not commented paragrath ...
3
votes
5answers
179 views
How shrink test -eq expression with more than one var value in /bin/sh
#!/bin/sh
if [ $num -eq 9 -o $num -eq 75 -o $num -eq 200 ]; then
echo "do this"
elif [ $num -eq 40 -o $num -eq 53 -o $num -eq 63]; then
echo "do something for this"
else
echo "for other do this"
fi
...