Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.).

learn more… | top users | synonyms (2)

0
votes
0answers
18 views

Manipulate Windows Program Through Wine in Bash Script?

There's a Windows program called Visipics. It finds similar images, not merely duplicates. I find it superior to findimagedupes and competing Windows programs, and it works well with Wine. I use ...
7
votes
1answer
63 views

How to extract the string between two \n in a file

I have a file with pattern <span class="WebRupee">Rs.</span>\n29\n<br/><font style="font-size:smaller;font-weight:normal">\n3 days\n</font></td>, <td class=...
6
votes
2answers
265 views

Is there a way for shell script to know which program has executed it?

In *nix world, is there a way for shell script to have information about which program has executed it? Example: /path/to/script1 /path/to/script_xyz in this imaginary scenario, script_xyz would ...
0
votes
2answers
28 views

Preform operation in bash only if a variable is less than a second variable

I am building an OS for a virtual machine I made, and while progress has been coming along swimmingly, I have been stuck for a good several hours on what should be a very simple issue: I am designing ...
-2
votes
0answers
32 views

Script (shell or python) to update a web page every 5 minutes [on hold]

I'm trying to write a script (shell or python) to update a web page every 5 minutes. I tried this: import time from selenium import webdriver driver = webdriver.Firefox() driver.get('https://www....
0
votes
1answer
40 views

add multiple users to multiple servers [duplicate]

I have a quick bash scripting question. I'm trying to add multiple new user accounts to multiple RedHat servers in my environment. This the script I've come up with so far, but it's not quite ...
0
votes
2answers
38 views

if last 4 file size of a directory are same with each other then exit otheriwse continue [on hold]

Please give me any shell bash script that will help me doing following task: if last added 4 file size of a directory are same with each other then exit other wise continue Example : ls -l $...
1
vote
2answers
136 views

#!/bin/bash exponent

I'm having trouble running exponent operator in a shell script #!/bin/bash clear number1=8 number2=2 sum1=$(( number1 ** number2 )) echo "8 ^ 2 =" $sum1 it returns expecting primary: " number1 *...
0
votes
0answers
21 views

taking the input from one file and related info from another copy it to new file

I have a inputfile contains phone numbers like 7463213456 8725678845 In another file I have info for every file like 7463213456;553256324;HIW456DFC;base_rsa;VSHD*CFGH...................... ...
0
votes
3answers
48 views

How can I delete a line from a file when the line contains a specific string? [duplicate]

I have a file which is comma separated. I have to find specific text and then delete complete line. e.g. 123,aaa,bbb,888,8881 124,bbb,ccc,999,8881 125,ccc,ddd,888,8883 I have to delete the line ...
0
votes
1answer
9 views

Multilevel Menu-Submenu-Option bashscript ( If-Else vs Switch-Case ) [on hold]

I'm asking for suggestion which one is better for Menu-Option especially for the process after you choose option it will have a option back to the menu. Please see below [Menu] 1 - Option 1 2 - ...
0
votes
2answers
24 views

Removing space at the beginning of the variable data

I would like to ask if how can I remove the space in the beginning of the stored data of the variable. I had an auto-generated script that will get MySQL COUNT from the DB. MYSQL COUNT SCRIPT-> .ini ...
1
vote
0answers
32 views

mutt doesn't run as a cron job wrapped in a bash script

mutt runs correctly like this: $ cat /home/user/test this is a test $ mutt -s "test" to@destination.org </home/user/test If I put this inside a bash script (stored in tmp1): #!/bin/bash /usr/...
0
votes
2answers
53 views

How to execute a shell script from anywhere on my server?

So basically I have a JS app that is inside a directory in /var/lib/app/. To start this node app I execute a start script startapp.sh from inside the directory. Now I need it to start at boot time, ...
-1
votes
0answers
19 views

Monitor Script for a specific oracle process which pegs my CPU to 100 % [on hold]

I need a shell script on AIX which can monitor a specific oracle process "ora_e00", this process is often pegging my CPU 100%, so I need to be notified by mail before killing it.
3
votes
1answer
36 views

“) Syntax error Invalid arithmetic operator (error token is ”

I have commands in a bash script getting data from a source text file and then adding the value of a variable to it and using it in an if/else condition. Source data file (db_count.ini) (Note: ...
0
votes
0answers
18 views

Input Return Key In A Sql script

I have a sql script which when run prompts me to input a value, if i don't input any value and press the enter/return key it will select the default value and will pull all the records. I am trying to ...
0
votes
1answer
48 views

How to actively grep log for the last 15 seconds for a phrase?

I have this bash script and inside the script, I am trying to grep a log for the words "status change" and then after I find the most recent line that contains the words "status change" (aka the most ...
2
votes
1answer
45 views

Cut string from command output

I would like to cut 150.8 from this string temp1: +150.8°F (crit = +197.6°F). Here is my script for logging temperatures with the command sensors: #!/bin/bash now=$(date +"%m_%d_%Y") # ...
5
votes
2answers
385 views

Shell script: if multiple conditions

I want to create a shell script that echos something if 3 directories don't exist. Here is the code I wrote: test.sh: if [ ! -d "/home/unix/POSTagger2" ] || [! -d "/home/unix/POSTagger2/stanford-...
1
vote
1answer
32 views

Rename multiple directories at once

I have a project with many directories named proj $ find . -iname proj ./include/proj ./src/proj ./lib/proj ./share/proj ./doc/proj I want to rename all these directories to test with -exec mv. I ...
1
vote
2answers
38 views

Condition Inside String in Bashscript

I want to print exit code of previous command in shell if it failed. So I changed PS1 variable in /etc/bash.bashrc like this: PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w [$?] \$ ' #...
-3
votes
0answers
31 views

How to find sum of 2 columns in multiple line records file

I have file that looks like: .Employee name:ABCD department:1 salary:1200 bonus:120 - .Employee name:Aaa department:2 salary:1800 bonus:200 I want to create csv file called Employee with records ...
0
votes
4answers
45 views

read phone numbers from file and store them in other file uniquely

I have input text file e.g myfile.txt which is contains data like WO_ID ------------------------------------------------------------------------ moveover_virus_8493020020_virus.final ...
0
votes
1answer
37 views

How to use a for loop inside an echo statement which is used to print statements into another script in UNIX

My shell script contains a function which is used to print statements to another shell script function print() { echo " insert() #insert function for i in $InsertFile1 ...
2
votes
2answers
52 views

How to assign value to input variable in shell

I am asking user for input and taking input in the variables such as $1, $2 etc. I am checking the variable for null value and wants to replace the value if null. if [ "$2" == "" ]; then 2=value fi ...
1
vote
1answer
26 views

Get Timestamp 00:00:00 Yesterday in bash shell

I have a script want to get timestamp in begin yesterday (00:00:00 GMT+0) but cannot excute this script dateto=$(date --date="1 days ago" +"%Y-%m-%d") datetoj=$(date +%s --date "$dateto 07:00:00") &...
0
votes
2answers
40 views

Define a set of values for a variable in shell script

I want to define a set of values for a single variable. E.g. singleDigit={0,1,2,3,4,5,6,7,8,9} If the user gives 10 it should exit with an error. How can this be achieved without using a loop, but ...
0
votes
1answer
25 views

cannot open file as first argument [duplicate]

I am trying to run a script like : ./script.sh file but I am receiving ( if I use a txt file ): =: cannot open `=' (No such file or directory) test.txt: ASCII text Second If I use a gz ...
-2
votes
2answers
43 views

Find ONLY the difference (extra) between two files in unix

I have 2 files. names1.txt and names2.txt. I need to know that which names are present in names1.txt but are missing in names2.txt. Then I need to store them in another file missing_names.txt. Diff ...
0
votes
1answer
58 views

Read Input From Command Line

Trying to use the "read command" to accept user input from the command prompt itself but my script doesnt seem to be moving forward echo "Do you want to continue?(yes/no)" read -p $1 if [ "$1" == "...
1
vote
2answers
42 views

Quoting the output of a backtick command [duplicate]

I'm trying to run an expect script that runs a telnet session to automate the sending of an email, I'm trying to pass the contents of a file as a single argument to my script but when the backticks ...
0
votes
1answer
27 views

Automate commandline application for another user

i have a problem with the following command. I want to write a script that sets the vncpasswd for another user. If I run the following command it will only work for the current user. #< echo "...
1
vote
2answers
50 views

Load plaintext output without write files

I have a program (than I run from terminal) that generates 4 plaintext files. For example ./myprog generates file1.dat, file2.dat, file3.dat, file4.dat. I want to create a script that allows me ...
-1
votes
4answers
40 views

Extract files from a directory and save the files' names and sizes in KB in a CSV file

I want to retrieve all the .log files from the directory /var/log, store the results in a csv file along with each log file's respective file size in kB. I started by getting the files using find: ...
0
votes
1answer
45 views

sed works on commandline but not in script [on hold]

Why does this work when I type it direct on the commandline: oldversion=12345 newversion=67890 sed -i "s/${oldversion}/${newversion}/g" "/home/user/MyDir_${newversion}/MyDir_${newversion}.reg" But ...
0
votes
1answer
61 views

mv not working in script, but works fine on the commandline

I am trying to put together a simple script that renames a few files and directories. If I type the entries directly on the commandline they work fine. But as soon as I put them in a script it doesnt ...
3
votes
2answers
141 views

SED challenge,aggregating String containing braces

I've been trying to use sed for aggregating a specific string pattern within a text for hours, but can't find the solution. I hope you guys know how to do it!? The text subject to my Goal consists ...
7
votes
3answers
662 views

How can I safely ensure a variable contains only a valid filename?

Given the script below, how can I ensure that the argument only contains a valid filename within /home/charlesingalls/ and not a path (../home/carolineingalls/) or wildcard, etc? I only want the ...
2
votes
1answer
40 views

Script to multiple number fields

I have a large file with loads of different text. I want to use a script that will go through the whole file and multiple the number by a predetermined amount, in this example 2 in the EXP="XYZ" ...
0
votes
0answers
16 views

print out anything in between “function $argument” to “}”, where $argument is the function name, of a given file [duplicate]

Let's say, i have some functions defined inside my ~/.zshrc function foo() { # do some stuff } function bar() { # do # lots # of # stuff } I search basically for a way to ...
1
vote
2answers
42 views

How to run a bash script from a sh(dash) script?

I have a sh (shebang #!/bin/sh) script (sh.sh) which invokes a bash (shebang #!/bin/bash) sub-script: . "some-path/bash.sh" In the bash script I have a declaration of an associative array: declare -...
3
votes
3answers
109 views

How to read a properties file into an associative array?

I'd like to read the properties in a properties file into an associative array. How can I do it? Specifics on what to parse: hash and equal signs. Everything else is a bonus. Properties file content ...
5
votes
4answers
476 views

How to check if any IP address is present in a file using shell scripting?

I have a script that generates some output. I want to check that output for any IP address like 159.143.23.12 134.12.178.131 124.143.12.132 if (IPs are found in <file>) then // bunch of ...
0
votes
0answers
13 views

My tcsh say “Unmatched” or “No directory or file found”

I have .csh script. When I want to execute it with source 8.csh Some times it says, no directory or file found some times it says unmatched. I realized another problem too. I can see 8.csh in ...
3
votes
1answer
35 views

Ordered by insertion Map in bash

Is there an ordered (by insertion) map in bash? I know there's an associative array data structure in bash, but when iterating over it, the order of the elements is not by insertion. Example below. ...
1
vote
1answer
34 views

Put console on ttyS0 if guest OS is booted headlessly

We're using Debian 4 (No systemd) for our product. I run it as a guest OS managed by VirtualBox for testing purposes. Here's how I use it: For manual debugging, I have the guest OS's console on ...
1
vote
0answers
13 views

Modification of the sql loader control file [migrated]

I am working on a script which uses the sql loader to load data into a table . However , anywhere I search about the control file of an sql loader I am seeing only statements like "load data into ...
2
votes
2answers
72 views

how to send integer as a parameter [closed]

I need to write a script in Linux. I want to execute a function several times with a different parameter in each iteration. I write the following code: #!/bin/bash bash << _EOF_ for ((i=0; i&...
0
votes
0answers
27 views

executing shell script from launcher, slow to end/complete the script

I am using a bash script to rotate my screen via xrandr. To make it easier to use I added the script to the unity launcher. The problem I have encountered with this is that the script seems to ...