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

learn more… | top users | synonyms (2)

1
vote
0answers
12 views

Avoid delays from network calls in logon and logoff scripts

I'm trying to tune some scripts in my test environment. My test environment is specialized and it exists to test software. The software includes Botan, Cryptlib, Crypto++ and OpenSSL. Whenever I log ...
0
votes
2answers
36 views

variable interpolation in shell script

I wrote the following shell script for a pg backup: #!/bin/bash PG_USER=donato DATABASE=mydb SERVER=216.58.219.174 DIR="$HOME/pg_bak" DATE=$(date +"%m_%d_%y") FILE="$DATABASE_$DATE" ERROR_FILE="$...
-2
votes
1answer
55 views

Bash script if - else contitions [closed]

I would like to do create a bash script that downloads a specific installer from the internet, installs it, create a desktop file that launches it, make it auto start, then remove the installer, but ...
1
vote
1answer
36 views

Convert GPS coordinates with bash script

I need to convert to a specific format some gps coordinates which are the output of the exif information of a picture. This is the typical output: exif:GPSLatitude: 10/1, 10/1, 10/1 exif:...
3
votes
1answer
54 views

Parsing a C string literal in shell

I have a valid C string literal that I would like to convert to its actual representation. Sadly the %b conversion specifier for printf does not define escapes for ? ' and ", which are all valid in a ...
-2
votes
2answers
62 views

Find all line in a file which start with g or any digit from 0to9

How do I find all lines in a file which start with g or any digit from 0 to 9? Can any one help me using command line? I try and I know how to do if start with g but don't know how to do with g and 0 ...
-3
votes
3answers
69 views

If, Then, Else Scripting

I have a log file that contains several lines, each with an IP, username, and URL. I need to create something that will take each IP in the line and, if starting with a 10 will append the word "ON" to ...
-3
votes
1answer
54 views

Search a file in unix system

I am trying to find a file using find and locate commands. locate command is faster but it requires to update the slocate db. And find command is slower but it wont require any updates. I am trying ...
2
votes
1answer
50 views

backup file locally in shell script

This is my crontab: crontab -e 30 5 * * * sh /home/donato/Documents/pg_bak.sh Every day at 5:30am I want to execute a shell script I created called pg_bak.sh. This is the contents of the shell ...
1
vote
2answers
72 views

how to edit next line after matching pattern and append the line if doesn't exist

I am looking for changing a file content which is repeated twice with that replacement I want to add extra line to second content in the same file Example file User YOURNAME IdentityFile ~/.ssh/...
1
vote
1answer
42 views

Replacing variable containing \ with sed

i am trying to replace $old string with $new string in file where: old=ESX_10.1.1.1\@11.11.11.11 new=host_15_11_0_111.static I am using sed command: sed i "s/${old}/${new}/g" /filename but it ...
0
votes
1answer
25 views

User Input Shell Script Syntax Error

I'm new to shell scripts and all, and wanted to write a script that would automatically perform this command for me: sudo aireplay-ng -0 (given number) -a (Router MAC Address) -c (Target MAC address) ...
1
vote
1answer
32 views

using a bash script to run an interactive program

this is day one for me for bash. perhaps this question has already been asked, but i've tried google and have come up empty. maybe because i don't know how to articulate my question. i have a ...
2
votes
3answers
67 views

Why is my elif being treated as an else statement in my bash script?

I'm building a bash script that uses wget to GET information from a server using a REST api. I'm using getopts to parse options given to the script and then using an if statement to redirect the ...
3
votes
3answers
90 views

How to do a loop to process two input files

I am using awk to do match two files and then multiply the elements of file2 and file1. awk 'NR == FNR{a[$1]=$2; b[$1]=$3; next} /:/ || !NF{print; next} {print $1, $2*a[$1], $2*b[$1]}' ...
1
vote
2answers
46 views

Read n lines at once in a loop using bash script

I have a file in this format: Start tracing process 17134 17136 17137 17138 (/usr/sbin/nginx)... [...
2
votes
2answers
69 views

How to execute Command which is in a variable

My Condition is like below. Could anyone help please? SEARCH="find `pwd` -name" bash> $SEARCH resources.xml | grep $SEARCH_DIR | grep $1 | grep ‘cells’ But am not getting the pwd as referenced ...
0
votes
0answers
31 views

How I can directly login to rails console through ssh?

Time to time I repeat the following commands: ssh username@servername cd /projects/rails_project bundle exec rails c production I want to create a shell script, and make alias for this file for run ...
0
votes
0answers
60 views

How to write Shell Script for Mongo Find query.?

i am new to Shell Scripting, Actually i am writing a shell Script for mongo to find specific document, this Shell Script Except a Argument and use in Find Query, So i had write a simple find query: ...
0
votes
1answer
43 views

I accidentally copied part of /* to /some/directory, how should I fix my mistake?

I did something stupid on a remote linux server: my working directory was /some/directory I ran for dir in $(ls | grep "a_pattern"); do mv $d/* ./my_subdirectory; done Now /some/directory/...
1
vote
2answers
69 views

Rename all spaces in image file names inside html php files

Inside different htm.gz, html.gz and php.gz web files I have images and the ones in .jpg format have name with space instead of "-", but in /images/ directory where all images are located they have "-"...
0
votes
1answer
24 views

use of lockfile in script and it significance

I have a code in which below line is used due to which i got stuck.I have hunted the web but did not understand well.just got to know the basic set of info as below lockfile can be used to create one ...
1
vote
2answers
55 views

How to check if some recurring text is missing in a text file?

I have a text file that looks like this: { "mimeType": "web", "body": "adsfdf", "data_source_name": "abc", "format": "web", "url": "http://google.com/", "urls": "...
0
votes
1answer
36 views

What is the most efficient way to check if Node is currently installed?

I am writing a script that will first check if Node is currently installed, if not it will install the latest version of Node. If it is installed, then it will proceed to another function to update it....
1
vote
2answers
32 views

Cronjob runs a script which calls another script

my cronjob look like this: 0 3 * * 0-6 somedir/promotionscript But promotionscript is actually calling another file "config" located in the parent folder of somedir. #promotionscript #!/bin/csh ...
2
votes
1answer
33 views

Sending a text from script to a screen

My whole task sounds like this "Show how many users are working right now, whenever someone has logged out or has logged in, print the new amount of users. Create a new screen and print there text ...
1
vote
1answer
41 views

How to :Autorun scriptshell after user log-in

I am writing a program in java programming language on Raspberry pi. As you know Raspberry pi is working on Rasbian Unix based OS. I have created my java fx gui application and set it to myscript ...
-2
votes
2answers
37 views

Data Manupulation required your help

I have a data as mentioned below. host_name Server1.domain.com contacts DL - Desktop contact_groups ravi, raj, rahim host_name Server2.domain.com contact_groups DL-Server host_name Server3....
1
vote
1answer
37 views

Using Grep In For Loop

File1 contains: 421 RP-001 421 RP-002 421 RP-003 550 SC-001 550 SC-002 550 SC-003 550 SC-004 550 DY-001 550 DY-002 550 DY-001 550 OU-001 550 OU-002 Script: #!/bin/bash Elogs=/home/elogs.txt ...
1
vote
1answer
67 views

Convert vertical array data to horizontal array data

I have a file with 25 matrices in a file, and each matrix is has 128 rows and 5 columns. Each matrix are putted one after the other, in a vertical way. Like this File input(file1): Array1 Array2 ...
0
votes
1answer
37 views

How do I find the version of JQuery that is installed on a Linux web server?

All the methods I found on the Internet involved using a .jsp page and a web browser. I have Linux servers with no GUI desktops. I do not want to use the web browser on a desktop to view a .jsp ...
1
vote
1answer
47 views

Awk hangs during math operation on Solaris

I'm working on a SunOS 5.11/Solaris 11.3 machine. I have a bash script that calculates and exports CPU frequency because I use it frequently in some test scripts. Here are the two lines of interest: ...
1
vote
1answer
56 views

Install command if command doesn't exist [closed]

I have this set up in a Makefile. ARG_2 := $(word 2, $(MAKECMDGOALS)) command_exist=command -v $(1) >/dev/null 2>&1 command_not_exist=! command -v $(1) >/dev/null 2>&1 npmig: ...
7
votes
2answers
131 views

How to log calls using a wrapper script when there are multiple symlinks to the executable

Long story short: I would like to track the way in which some executables are called to track some system behaviour. Let's say that I have an executable: /usr/bin/do_stuff And it is actually called ...
1
vote
3answers
98 views

Copy command with command line arguments

I am writing a simple script which will take a keyword. Then, it will look for files in the directory which contain that keyword and copy them to another directory (name of directory = keyword). The ...
2
votes
3answers
233 views

Append data of multiple files to new file separated by a line

I have more than a hundred firewall rules for many different customers in discrete files in a folder. Suppose the filenames are: 1.wawa.com_firewall_rule 2.newa.com_firewall_rule Each file ...
0
votes
1answer
37 views

How to save the grep o many files

I am using grep to catch a part of many files, which has name 001.log, 002.log, 003.log .... I need to save the grep as a different file grep -A3406 -P 'Molecular' *.log And to output the grep ...
1
vote
1answer
41 views

Determine if there is any VNC display desktop active and its number

When SSH loging into my Linux computer, how could I know if there is any X-Windows desktop display session (i.e: :1 started by VNCServer) active and what is its number? Reason: I sometimes remotely ...
0
votes
0answers
28 views

Rename the file unix file with cycle date

Input_20160603162112775231.txt is sample file. This file has "Input" is file name and 20160603162112775231.txt is cycle date but I would like to rename the file with Input_20160603.txt
0
votes
2answers
47 views

How to fetch all the even lines and odd lines from a file and save them into two different files such as Evenfile & Oddfile? [duplicate]

The question is very simple. Suppose I've a file named "a.txt" and it has 100 lines. Now I want to extract odd lines i.e lines 1,3,5...etc and save them to a different file such as Odd.txt and the ...
2
votes
1answer
50 views

How to choose the highest number element in many files with many arrays

I have many files which each one contain many arrays(like input 1 and 2, below). Each array has two element numbers in the second row. I need to use a logical criterion to choose the highest number ...
0
votes
2answers
40 views

Sum column numbers elements in many arrays

I need to sum the the numbers located in the same column in an array. The input is: 1: 6.1703 44 3.5 0.3 46 7.3 2.3 2: 6.1932 44 5.29379 2.9 46 1.72261 7.2261 3: 6.5664 45 4.756 5.6 46 1.6 2.5 4:...
1
vote
1answer
42 views

Output broken when appending output of sql query in ksh

I'm very new to scripting. I would like to add the output of the sql function given below to another variable for example: month_end () { mdate=$($SQLPLUS_HOME/sqlplus.exe -S $DBC << END set ...
1
vote
1answer
41 views

sh script containing perl element does not produce same output via crontab as manual execution

I tried posting this on Stackexchange but I think I may have more chance of a correct answer here as its very linux specific. I have an sh script which updates data in a csv, then runs a perl script (...
0
votes
5answers
97 views

How to view files that have read permission only in my present working directory?

This question seems an easy one for anyone who knows find command. But let's assume that find command doesn't work on my system. How can I view the files based on their permissions without using "find"...
-1
votes
1answer
54 views

Extract Information From Logs

Unable to grep third field "Email From": While I'm using this command to grep first two fields: echo "TimeStamp Email To: Email From:" && awk '{print $1,$6}' logs Logs: 2016-05-23 11:01:...
-1
votes
1answer
46 views

How to automate putty commands when connection is through ssh? [closed]

Two files are there. I want to run cmds.txt cmd in ssh port connectivity . how to run txt file with putty. plz suggest some ways. if suppose this is a sv.bat (batch file) Inside batch file there is ...
0
votes
0answers
44 views

Help on negative numbers in an if statement

I am writing a script to automatically rotate the screen using a laptop's built-in accelerometer. Currently rotating the laptop in one way works, (and it also goes back to normal when putting it back ...
2
votes
2answers
37 views

while iterating over the directory, test to see if the items are files or directories

First, I am newer than new, I'm sorry this is so long, but the forum rules ask for details. Also sorry this is printing out weird. Here is what I am trying to do: I am stuck on part (B) The ...
0
votes
0answers
28 views

Debug a script that is in your PATH?

script is a shell script that can be found in PATH directories. To run it in debug mode, can I use something simpler than: sh -x $(which script)