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

learn more… | top users | synonyms (1)

1
vote
1answer
18 views

Hostname variable doesn't work

I'm on a Raspberry Pi using RPiTC (Raspberry Pi Thin Client). I had made a script with an Hostname variable. It's worked perfectly but today when I had launch my script I saw something strange. My ...
0
votes
2answers
29 views

Locate specific file from script

I've written a script file in which, one function searches for another script and if found, executes that script. Script extract #!/bin/bash ... service_status() { local my_script=`which ...
2
votes
2answers
35 views

Can you make a process pool with shell scripts?

Say I have a great number of jobs (dozens or hundreds) that need doing, but they're CPU intensive and only a few can be run at once. Is there an easy way to run X jobs at once and start a new one ...
1
vote
2answers
40 views

script that lists all files in a directory and subdirectories sorted by size, listing only file names not complete paths

I'm looking for a script that lists all files in a directory and subdirectories sorted by size, listing only file names not complete paths. find . -type f -exec ls -lhS {} \+ works but gives the ...
0
votes
1answer
35 views

finding and replacing text [duplicate]

Does any one know how to find and replace text in a file. it can be implimented into a bash file. i would like to find the line and the output the text to it the file can only be opened with the root ...
0
votes
1answer
13 views

Universal .bashrc alias showing results of sysytemctl start command

This is small .bashrc alias that allows me to see results of starting service alias systemctl start apache='systemctl start apache && echo SUCCESS || echo failure' How can i modify to work ...
0
votes
1answer
9 views

How can I pass a function name to a test runner?

I wanted to write my own test runner: do_test () { function_under_test=$1 expected="$2" function_under_test $3 # <-- Line 32 if [ $result -eq $expected ]; then printf '.' else ...
0
votes
2answers
31 views

Why do I get Illegal number: {1..3}

Why am I getting ./6_sum_square_difference.sh: 11: ./6_sum_square_difference.sh: Illegal number: {1..3} for #!/bin/sh summing () { the_total=0 num_in=$1 for one_num in {1..$num_in} do ...
2
votes
1answer
26 views

Easy command line method to determine specific ARM architecture string?

I'm trying to write a script which will determine actions based on the architecture of the machine. I already use uname -m to gather the architecture line, however I do not know how many ARM ...
0
votes
1answer
45 views

Why does this comparison return not equal?

Can't seem to get this to evaluate to true is_equal () { in="$1" if [[ "$in" == "385" ]]; then return 0 else return 1 fi } a= is_equal 385 if [[ "$a" ]]; then echo "equal" else ...
0
votes
0answers
41 views

Increment Numbers in URL?

I want to create a list of URLs. The URLs have two sets of identical numbers which need to be incremented by 1: http://sample.com/poilus/cwrgshs/192/192.html ...
-1
votes
1answer
23 views

Check exist file on another pc

Yesterday I had ask how to use my tftp protocol in my bash script: Debian - Using TFTP in a bash script And now I have a problem with my tftp protocol. The file who was taken depend of my Hostname. ...
0
votes
1answer
36 views

Debian - Using TFTP in a bash script

I'm actually using RPiTC (Raspberry Pi Thin Client). I had create a script to see if my Hostname has the same name than a file. And now I want to say "If my Hostname don't have the same name than my ...
0
votes
2answers
30 views

Multiply a column using awk

How do I multiply a column by an integer (say 3) and replace the older value by new one, using awk? Input: Data 9390.900391 10573.089844 80.000000 200.000000 2.700000 Data ...
-2
votes
2answers
24 views

How to use shift to shift $@ one over

I am running a shells script with 3 arguments. I am getting the word count of each one. But I want to skip over the very first argument, maybe by using shift or something else. Most of the examples ...
1
vote
1answer
21 views

Compare two Arrays in KSH and output the difference

I am not extremely familiar with KSH (Actually just started using it) and I am having problems with trying to create a script that will essentially compare two arrays that have been stored and then ...
0
votes
1answer
30 views

How to make $@ start one iteration ahead

I'm running a bash script and am reading file contents of each one, but I want to skip the first one. I know of the "shift" command, but I'm having trouble getting it to go one over. I currently have ...
1
vote
3answers
41 views

How to access the contents of a file that is used as an argument when running a bash script?

I am running a bash script with its parameters/arguments as files. From inside the script, how do I get the contents of those files? I run the script with this command line: sh script_name ...
-2
votes
2answers
26 views

extracting only the domainname, port number of first path

str1="https://111.111.111.111:2222/cpsess8993738132/scripts4/listaccts/" str2="https://111.111.111.111:2222/cpsess8993738132/" ...
0
votes
2answers
52 views

Running a program (command) on terminal after login screen in Ubuntu 14.04

NOTE :- This is not a duplicate question. I have searched about 100 times on this site and several others including Ubuntuforums,askubuntu and stackoverflow. I couldn't get my work done. OBJECTIVE :- ...
1
vote
1answer
42 views

Using cURL, How can I fetch a numerical string which contains commas and spaces and convert such to a NON COMAFIED string [duplicate]

Example: Google's Outstanding Shares are 670,000,000 and this value is collected in a txt file from Yahoo Finance API using the below script. The issue is; that numbers WITH commas or spaces are ...
-4
votes
1answer
63 views

Merge two csvfiles by column header

I have two csv files: success.csv "ID","Legacy ID","Field1", "Field2" 1,1111,google,news 2,2222,yahoo,news error.csv "Legacy ID","Field1","Field2","Message" 3333,aol,news,"Failed to upload ...
0
votes
2answers
26 views

I'd like my script to interpret links when processing files

> ls -l aliasedname lrwxr-xr-x 1 anon3202 users 19 Dec 25 05:24 aliasedname -> www/realfilename I'd like for my script to return details about ~/www/realfilename when it's fed information ...
-2
votes
0answers
32 views

how to get out of PID and port of Solaris 9

Server and the port list are taken from a file "demo", I need the port's process ID to run the ps command. #!/bin/bash while read -r -u10 server port line do echo ========== server: "$server" port: ...
1
vote
2answers
32 views

Help with Script to Process txt file to CSV

I am trying/attempting to write a script to turn this: Mikrotik01#show unique routing entry | 192.168.255.232 | inc ID Thu June 10 15:21:32.808 CST Unique Entry: 192.168.255.21 Unique Entry: ...
0
votes
1answer
32 views

unable to read the output to run the next command [closed]

When this script is executed I get the PID. Now I want to read the output "PID" and run the next command in this way: ps -ef | grep -i PID ps -ef | grep -i PID while read -r -u10 server port ...
2
votes
0answers
45 views

“Restart” a process in the same terminal?

I put "restart" in quotes because the following question on SO illustrates what I'm trying to do: http://stackoverflow.com/questions/27957091/restarting-a-process-in-the-same-linux-terminal I'm ...
1
vote
1answer
31 views

remove a portion of a line contained within two different types of separator / delimiters [duplicate]

Most of the commandline tools I'm looking at have the ability to pick a field delimiter. However, I'd like to pick one delimiter to start, and a different one to end the segment of text I'd like to ...
3
votes
0answers
28 views

How do I schedule a cron task to run

I'm looking to crontab a script every hour starting Friday at 5pm... ending Monday at 5am. This script checks if it's completed this week and if it's currently running. If no/no, start task. Off the ...
1
vote
0answers
46 views

script needs to add another loop

script which runs netstat -tulpun | grep -i port_from_the_list & takes the output for running the next command I need to run 2 command on all the server mentioned in the list. server: Jan port: ...
1
vote
2answers
20 views

remove lines from an output file from diff

I have a script that uses diff -c then puts the output on a text file. What I want is to remove the line that does not have the "!" and display the lines with the exclamation mark. Is this possible? ...
-1
votes
2answers
37 views

Script which takes details from file & runs command

It would be helpful to understand how can I connect the second column in the script. currently using the below for loop for i in cat server do echo ===$i==== ssh -q $i 'netstat -tulpun ...
2
votes
4answers
92 views

Fastest way to read last line within pattern of multiple files with the same extension

I have in a directory /home/files/ some files that all have the same extension .txt. For example 1.txt 2.txt 3.txt 4.txt 5.txt test.txt These files are all the same in data format but the data are ...
1
vote
1answer
29 views

I'm copying if-then statements, with slight variations… and I shouldn't have to

I know there's a better way to do this, I'm just not looking in the correct place to figure it out. I have a number of these type of statements (say 1-100, or a list of different filenames). ...
0
votes
1answer
64 views

How do I put a checksum in a script?

I was (am) having trouble installing Eagle on my Linux (debian 8 jessie) computer. I was reading the installer script, when i noticed there is a checksum for the install script in the install script? ...
0
votes
2answers
49 views

Whats wrong with this case statement?

UPDATED: I am trying to do some color changes with my keyboard using apexctl depending on what time it is. But my case statement is giving me trouble. I want to compare the time when the script runs, ...
-2
votes
0answers
24 views

Extracting soft clipped sequences

I have a file like this SRR959756.2011 256 20S24M GCCGGGCGCAGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAG SRR959756.2011 256 19S22M3S GCCGGGCGCAGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAG SRR959756.2011 256 ...
0
votes
0answers
16 views

What's the difference between `set` and `modify` in *nix command syntax

I'm creating a new custom script that will be able to add, modify|set and delete certain rules of DNS records. I was looking for a proper naming convention of *nix tools that might help me name the ...
-1
votes
0answers
25 views

How to run a script when install a rpm package and answer the installation questions

I will like to know how to install the RPM and answer the installation question automatically if is possible. any ideas.
2
votes
2answers
41 views

Changing variables in a forked process from outside that fork?

In theory with this block, you should only see "running..." once(or less), but in practice, it repeats until it's manually killed. How do I change the value of x inside the forked process to false ...
1
vote
3answers
120 views

Can I make [ $(($1 % $check)) -ne 0 ]; be more performant and not be killed?

If have the following code which works for up to 13 (line 2) in a few seconds but when I try and do upper teens and 20 it gets killed after a couple of minutes. divisible_by () { for ((check=2; ...
0
votes
1answer
82 views

VLC script on ubuntu server

I need a small script which run three vlc command on the same time (on Ubuntu server 14.04) as stated below: #!/bin/sh cvlc -vvv v1 --sout ...
0
votes
1answer
36 views

How i make this script execute every minute without cron? [duplicate]

I have this: #!/bin/bash wlan=`/sbin/ifconfig wlan0 | grep inet\ addr | wc -l` if [ $wlan -eq 0 ]; then echo wlan0 not connected, connecting... echo sudo ifup wlan0 logger wlan0 reconnected. echo ...
0
votes
1answer
28 views

Disable log of specified crontab item

How can i disable logging for specified item/line in crontab? (i´m on debian/raspbian) I have a script that checks if wlan0 is up every minute, but i don't like that cron logs every minute on syslog ...
2
votes
0answers
42 views

Bash Executing Script from within Script Causes Echo and Read Issues [closed]

I appear to be having unexplainable issues with scripts run from within a subscript. I've been unable to acquire a solution so I will give you what I can to help me solve it. Problem: when a script ...
0
votes
1answer
41 views

bash shell - how to do nested loop without “syntax error: operand expected” [duplicate]

I am trying for i in {4..100} do is_prime=true a=$(($i-1)) for divider in {2..$a} do b=$(($i % $divider)) # <-- line 9 [ $b -eq 0 ] && echo 'y' #is_prime=false done [ ...
5
votes
1answer
123 views

echo colored text which changes colors dynamically

Is there any way that i can print a colored text on console which keeps on changing its colors dynamically(with or without a specified time interval) just like some greeting cards in which the ...
0
votes
1answer
19 views

file deletion using forfiles

Trying to delete files in directories named "archive". I have not been able to figure out how to do this without specifcally entering every directory. There are other directories under the serial ...
1
vote
1answer
36 views

file name as argument and sort in descending way in perl?

I have this perl script #!/usr/bin/perl use strict; open my $df, '<', 'file.txt' or die "open: $!\n"; my %h; while (<$df>) { $h{$_}++ for split /\s+/; END{ for (keys %h){ ...
1
vote
2answers
44 views

Checking URLs for HTTP code 200

I have a text file containing a list of URLs like this: http://somesite.com/some-article/ https://anothersite.fr/somepage.php?page=something What I'd like to do is check which URLs return HTTP code ...