A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.
1
vote
1answer
22 views
value too great for base (error token is “08”)
Trying to do quiz 'max sum of 2 from grid'
Can't figure out how to get around the error below.
Feels like I'm missing something. Once I find out what I can update the question to be more general ...
0
votes
2answers
35 views
What is the fastest way to filter a string? [on hold]
I have a script that needs to pull the numbers from thousands of strings and anything I can think of is turning out quite slow (on the order of a couple hours). Assume that pretty much anything could ...
2
votes
3answers
73 views
Processing input line by line (with empty lines) from shell
In a shell script, I need to parse the output of a command line-by-line. The output may include empty lines, and these are relevant. I am using ash, not bash, so cannot resort to process substitution. ...
1
vote
3answers
128 views
Read longest line in file using while read loop?
I've been googling but I can't find any scripts that uses the while loop to read the lines. I'm stuck and I'm not sure on where to start
Heres the question:
Write a bash script longestline.sh that ...
2
votes
3answers
180 views
What is the purpose of a start up script? [on hold]
So far I know the basic meaning of a script, it is a file containing shell-commands made executable by chmod +x file and able to be run by ./ file.
My friend told me, he had to copy so called start ...
0
votes
0answers
28 views
What do i have to consider to write a script that reacts on a keypress?
I know i can read within a script something into a variable, like this:
variable = read
But i have to press enter in order to submit the value into the variable.
What do i have to know in order to ...
1
vote
0answers
23 views
Service script and shared libraries
I have the following simple script IPN in CentOS 6.5 in /etc/init.d/
#!/bin/sh
# chkconfig: 2345 05 06
cd /root/IPNHost
. /etc/rc.d/init.d/functions
start() {
echo -n $"Starting..."
...
0
votes
0answers
13 views
Python script: wait until job in tmux session has completed
I am trying to continuously run a python script with random parameters from another python script, where each run is in its own tmux session. A very simplified overview of what I'm trying to do goes ...
2
votes
6answers
71 views
Scripting to split a single CSV row into multiple
I need a script that can take a CSV file with that has a column of semicolon-delimited attributes, and break it into multiple rows to normalize that multi-valued attribute? Here is the scenario:
...
0
votes
1answer
54 views
How can I use a linux shell script to change directories and copy files?
There are several files I need to copy which are stored in different directories. The file names will all have two common fields that are distinctive for a particular date and time. I can usually ...
0
votes
5answers
46 views
How to Read string from file and compare to each line of second file
I'm making the post OS installation script that will include the Hardening section . And in this hardening section it will read the Kernel parameters from file A and compare to file /etc/sysctl.conf ...
1
vote
3answers
265 views
How can I pass on parameters 4..99 to another function
I'm calling a function and I want to pass up to 100 paramters onto another function. I do not want to pass on the first 3 params, I start with param4 being the first param for the other program.
I ...
0
votes
2answers
27 views
script for substition incremental
I have 4 machines, every machine(centos) has a ifcfg-bond1 with identical ip address 10.0.0.3
How to using bash and sed substituting 10.0.0.3 with a incremental value?
I want to obtain something like ...
0
votes
0answers
24 views
How to extract data from the file
How can I extract data from "config.tab" files located in different directory and put it in a single text file.
Example:
/servers/FRCOLP0056673/config.tab
/servers/FRCOLP0056674/config.tab
...
-1
votes
1answer
30 views
What is the best site or book for practicing shell scripting? [closed]
I have learnt shell scripting basics from internet, bash scripting guide and other resources. But now I want to practice shell scripting, can you please guide me where can I find good problems?
1
vote
3answers
42 views
Shell script to find and count total number of characters in all the files
How can I make a script that finds every file in your home directory that is less than 3 days old and then gets a count of the total number of characters in all of these files?
1
vote
2answers
44 views
Is it better to use a shebang line to execute a script?
I was looking up shebang and wondering why I would use it.
I could execute a bash script using:
bash foo.sh
or
./foo.sh
(with a shebang line in foo.sh)
What are the pros and cons of each and ...
0
votes
3answers
65 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
36 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
52 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
57 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
39 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
20 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
42 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
31 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
47 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
29 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
64 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
31 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
25 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
35 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
30 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
88 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
48 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
85 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
27 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
41 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
33 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
34 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
48 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
33 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
33 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
1answer
56 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
40 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
96 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 ...