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

learn more… | top users | synonyms (2)

2
votes
1answer
34 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
44 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
39 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
57 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
81 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
59 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
53 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: ...
2
votes
1answer
64 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
140 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
111 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
249 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
38 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
47 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
30 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
54 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
46 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
46 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
100 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
55 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
74 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
47 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
39 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)
0
votes
2answers
36 views

Bash apt-get updater script via desktop laucher

I have a basic apt-get updater script that I am able to launch as root on GNOME3 via the main menu (alacarte). I'd like to be able to launch this script by double clicking via the desktop while signed ...
1
vote
1answer
39 views

How to generate a set of new different files through shell scripting given a certain pattern name?

How to generate a set of new different files through shell scripting given a certain pattern name? Said I have this pseudocode: #!/bin/bash for i in {1..5} do ./processing < base.ppm > ...
3
votes
3answers
111 views

Extract string from a path

Problem statement: I want to extract an unknown string(last string) from a given path name in a single line command. Restrictions: The path is dynamic and can change with users input. Only last ...
1
vote
2answers
43 views

Automatic backup and exclude of certain folders

I have created the follow bash script to be used in cron for automatically backing up certain folders while also excluding certain sub folders: folders_to_backup=( "/first/folder/to/backup/" "...
3
votes
2answers
48 views

Overwrite specific line in file 2 with content of file 1 [closed]

I've got 2 files (file 1 contains only 1 line; file 2 contains multiple). I want to replace the 5th line in file 2 with the only line present in file 1. What would be the best way to do so?
2
votes
1answer
22 views

Strings from two distinct arrays not matching?

I'm trying to filter one array from another array. That is, I'm trying to create a third array with a logical not-intersection. The best I can tell, it appears this block of code never matches, and ...
1
vote
0answers
62 views

What is the difference between autossh and ssh that is put in a while loop?

From this website it says that: Autossh is a program to start a copy of ssh and monitor it, restarting it as necessary should it die or stop passing traffic. But I really can't see the ...
0
votes
1answer
44 views

How to multiply numbers located in two different files

I have two files ... First file(input 1): 1: 6.1703 44 14.7262 46 18.3255 2: 6.1932 44 52.9379 46 4.30653 3: 6.5664 45 2.82839 46 3.1275 4: 8.0923 44 14.1076 Second file(input 2): 43 ...
0
votes
0answers
32 views

Significance of shell script with XML

I have recently joined anew project and experienced the structure where Shell scripts are usually directed to a target which is set in XML and that XML containing action in the tags which needs to be ...
1
vote
1answer
44 views

How to add numbers in many arrays

I have a file with many arrays, which has "identifiers" numbers in the first column. So I need to sum the numbers located in the second column based on that "identifiers" . An example of the input: ...
3
votes
1answer
70 views

xterm not using .Xresources

I've one .xinitrc with the following lines: #!/usr/bin/env bash xrdb -merge ~/.Xresources & xset r rate 200 30 & xterm & #fixme: xterm is not reading loaded .Xresources exec /etc/...
1
vote
1answer
26 views

Reactivate stored pid of a window with xdotool

First, I store the pid of an active window. active_window_pid=$(xdotool getactivewindow getwindowpid) Second, I click on another window, which is actually function below. mouse_click 4000 1000 ...
1
vote
1answer
45 views

Will these commands return the same output on different Linux distributions? [closed]

I am writing a monitoring script. I am running it on a specific machine, and it works. It is planned to be ran on several Linux machines, not bound to a single distribution. Here are the commands and ...
0
votes
1answer
28 views

Why does the output look like different?

After executing this script, sometimes the output looks like this: 1912:! total e ergy = -1090.13343774 Ry 2310:! total e ergy = -1090.20757070 Ry 2709:! total e ...
2
votes
4answers
41 views

Why does “ $Namefile* ” give me such a result?

In my code , there is such a part ; Namefile=$1 for n in $Namefile* do echo $n done and just for this part's result is ; $ sh example.sh hw1 hw1_evening_sun.txt hw1_morning_sun.txt hw1_out_si_wire....
-2
votes
1answer
54 views

Script to count the number of numbers and letters in a file

Hello guys I'm literally stuck in this damn - before exam exercise. Exercise: Write a scrypt wich gonna handle a name of a file ( as a first Argument ) and count amount of those numbers and letters ...
2
votes
1answer
51 views

Accessing random array element in ZSH

I have ZSH as my primary shell, and I'm trying to randomise access to an array. I keep seeing feh called, but I don't have that command. I have _feh, but I don't know if it's the same thing. What is ...
1
vote
1answer
39 views

why the executing shell within cron job will take longer time than normal? [duplicate]

I have a shell script which will run project consist of multiple JUnit tests. Then I call this shell within cron job every a period of time. In this case, I observe the following: Time to complete ...
-1
votes
1answer
67 views

How to compose a list of all the executables that are used in a bash script?

Executables as a general term for: common binaries scripts I suppose it can be done with some fat regex, matching start of new lines, conjunctions like && and ||, inline after ; etc...but ...
0
votes
3answers
64 views

Regex pattern to replace multiple values via sed

I have a script in which I need to parse the IP address of the localhost, and replace the 2nd octet with a different value, but the value being substituted depends on what the value currently is... ...
0
votes
1answer
49 views

Send file as attachment without using mutt and uuencode

How can I send a file as an attachment via email in bash script, without using mutt and uuencode?
1
vote
4answers
120 views

Bash script to check if a file is modified or not

I try to write script to check if a file was modified or not. If it did, it should echo "Error!", if not - script keeps running. My script #!/bin/bash date=$(stat -c %y)$1 while true do ...
1
vote
3answers
128 views

Why this while-case does not work in Ubuntu?

I am switching away from BSD to completely Linux. Script in Ubuntu 16.04 #!/bin/sh while (( "$#" )); do case "$1" in -i | --ignore-case) [ $# -ne 2 ] && echo "2 arguments i ...
1
vote
1answer
49 views

How to sum specific rows of a matrix

I need to sum the matrix elements of specific rows for each column. An example of the matrix is given below(input). So the matrix has 4 columns and 6 rows of numbers. I need to sum the numbers of ...
1
vote
2answers
31 views

Execute default option when no options are specified in getopts

I followed the tutorial here to learn how to use getopts. I'm able to execute all the options properly provided by the user. But now I want to execute a default option when none of the options are ...