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

learn more… | top users | synonyms (2)

0
votes
1answer
38 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
110 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
118 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
46 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
25 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 ...
0
votes
0answers
27 views

setting input request in a script [duplicate]

I have a script which is interactive as shown below. Its creates a user and ask for the user password and then ./script Input User PW : ****** Do you want to execute ...
0
votes
2answers
53 views

How to run multiple scripts at a same time?

Suppose I want to run five different scripts at 3 PM on every Saturday and I want to put all these scripts in a single script and run it using cron.
4
votes
3answers
354 views

Executing of all shell scripts in a directory starting with the letter 'a'

I have many shell scripts in a directory starting with letter 'a'. How could I execute all of those shell scripts at a shot? Can we develop any other small script to run this?
1
vote
2answers
43 views

assistance with sh creation

I'd like some assistance with turning the below commands into an executable shell script (?sh?) sudo su export SLOTS=/sys/devices/bone_capemgr.*/slots cd /lib/firmware echo PRU-GPIO-Enable > ...
0
votes
2answers
63 views

I want to edit the text of a specific file

I would like to modify the configuration file, as shown below. What can I do as a shell script ? before Section "InputClass" Identifier "calibration" MatchProduct "Touch" ...
2
votes
3answers
63 views

Mysql output format in Bash Script

I'm writing a bash script where I'm using mysql query in that script where the format which I'm getting is quite different. Query: root@debian:~# mysql -u root -ptoor super_market -h 0 -e "select * ...
2
votes
1answer
39 views

Create multiple username and UID in Linux using shell script

In my environment I constantly have to attach an NFS server running on Linux. The Linux client system has user names created in it and they are in a sequential order. But in order to set the sharing ...
2
votes
1answer
45 views

Putting subshell in background vs putting command in background

I have two bash scripts that try to check hosts that are up: Script 1: #!/bin/bash for ip in {1..254}; do ping -c 1 192.168.1.$ip | grep "bytes from" | cut -d" " -f 4 | cut -d ":" -f 1 & ...
1
vote
1answer
79 views

Summarize certain data fields of apache CLF log file

I want to grep some information from raw combined log format apache logs: 51.254.56.62 - - [01/Jun/2016:20:49:28 +0500] "GET /vendors/jquery.slimscroll.min.js HTTP/1.1" 404 - "http://networkconfig....
1
vote
1answer
37 views

Array indexing using “sed”

I am working on one shell script which search directory modified in last 24 hours and then compress them using tar. Folder Search : find /path to log directory/ -maxdepth 1 -type d -mtime +0 ...
0
votes
1answer
40 views

sum of numbers located in different rows using awk

The following lines sum numbers located in the row #2 and row #3 , row #4 and row #5, row #6 and row #7 and so on (so, sum in a consecutive way). awk ' NR==1{$1=$1; print; next} !(NR%2){split($0,a);...
3
votes
1answer
34 views

Storing stderr output in a variable without modifing stdout, and doing so repeatedly

there are many "almost duplicate" questions, but none gave me the answer I'm looking for, so bear with me. consider a simple server API, in which you can consume data in iterations, using a "...
1
vote
0answers
30 views

Maintaining a window open until completion of another task [closed]

Aim: keep a GUI window open only for the duration of another command/script being run Current Method for this: When current time matches command/script completion time, close the GUI window I'm ...
4
votes
3answers
66 views

How can I respond to a prompt within a shell script running in background?

I am scripting the installation of software on HP-UX server. Once the script starts it provides a prompt where I am to enter the install path. I need to pass the path to the script so it can ...
1
vote
3answers
43 views

Help in separating columns from command into a new command

I'm a noob scripter, and I'm trying to create a script for automatic device creation. I'm pretty far already, but I am stuck at one point. The source file looks like this: dev1 size 1024 dev2 size ...
3
votes
2answers
70 views

Compare lines and upgrade two different files

I have a couple of text files with the following features: $ cat file_1 Line A Line B Line C Line D $ cat file_2 Line A Line added 1 Line B Line D Line added 2 They are such that file_1 has some ...
1
vote
1answer
36 views

Pipe blocks with the following sequence of commands [duplicate]

I have a script that reads a file that contains urls and then prints out the ip addresses. However, I am unable to find resources as to why the pipe blocks when I add the command cut -d" " -f4 at ...
12
votes
3answers
868 views

How to remove \n between the outputs of two echo commands?

I have a text file containing one file name in each line: 111_c4l5r120.png 123_c4l4r60.png 135_c4l4r180.png 147_c4l3r60.png 15_c4l1r120.png ... I want to convert it in this shape: 111_c4l5r120.png ...
2
votes
2answers
20 views

Simple Korn shell script needed to list out all files created/modified after tidemark date

How to list out all files created/modified after a particular tidemark date? If my tidemark date is '30-May-2016 08:06:49' then I need all files/directories generated/modified after that date&time....
2
votes
2answers
63 views

how can I find files based on different names and delete all them in one single line [duplicate]

Finding files based on different names I know how to do. The problem is that I don't know how delete all of them at once. I am using OMVS in z/OS390. To find files searching by different extensions I ...
-1
votes
2answers
163 views

How to sum many numbers inside 2D array using awk

I need to sum numbers located in a file like this one: column1 column2 column3 row1 a(1,1) a(1,2) a(1,3) row2 a(2,1) a(2,2) a(2,3) row3 a(3,1) a(3,2) a(3,3) row4 a(4,1) ...
-2
votes
2answers
183 views

Unix for loop and grep combined ksh hp-ux

What if you have 5 or 6 files, specific files .biz in a directory, and you want to store them one at the time in a variable $file, and apply a set of command until no more .biz file are found in the ...
1
vote
2answers
46 views

Compare string in two files And Merge its Output

I am trying to get the bandwidth of the domain from one file and its hits details from another file. The format of the two files is as follows: bandwidth.txt aadrivingschool.ws 2840.36M ...
1
vote
0answers
37 views

How tcan I delete columns from a file without losing the format? [closed]

I have a file with this information: 1 2 3 4 5 O O O O O Eigenvalues -- -20.44628 -...
0
votes
0answers
13 views

shell script to start multiple android emulators

i want to write a shell script that starts android emulators i.e the emulators have been created in android studio now i want that those scripts without starting android studio or using terminal start ...
3
votes
6answers
734 views

How do I remove a words ending in the letter S if duplicates without an S on the end are on the same list?

I have a large list of words. Many of the words are only different because they have the letter s on the end. If a word on the list is the exact same as another word on the list, except one of the ...
3
votes
2answers
43 views

How to get character level difference using “diff” command in Linux using shell script?

I have two SQL files, one is old.sql and the other one is new.sql. Suppose old.sql contains a table with three fields, Emp_Id, Name and Address and data stored in old.sql as follows: Insert into ...
1
vote
3answers
42 views

how to make a large command line broke in two lines be executed as a single line inside of a script

I am very begginer with Unix. I am using IBM z/OS390 and I am using the OMVS shell. I don't have "vi" installed at all so I use "oedit". If I try to initialize the app.jar straigh from OMVS shell it ...
2
votes
1answer
73 views

How to sum numbers inside many 2D arrays

I need to sum numbers located in a file like this one: column1 column2 column3 row1 a(1,1) a(1,2) a(1,3) row2 a(2,1) a(2,2) a(2,3) row3 a(3,1) a(3,2) a(3,3) row4 a(4,1) a(4,2) ...
1
vote
1answer
29 views

What is the curl equivalent of this wget command?

I'm trying to switch over part of a script from wget to curl. I have this command: wget --output-document=dl.html --quiet --timeout=10 --tries=1 $URL What's the curl equivalent of this?
1
vote
0answers
36 views

Bash script, string spaces handling [duplicate]

I'm writing a script that will automatically sort my albums on my NAS server and encountered the following error. Whenever I have a space in an album name I'm getting an error. Albums can be either ...
1
vote
1answer
34 views

Point and click Ubuntu 16.04 bash script randomly alternates output behavior

I wrote and tested the following point and click Ubuntu 16.04 bash script for the purpose of completely killing a mono-service RecorderManager.exe process by literally killing the process id returned ...
-1
votes
2answers
36 views

script for Monitor the file for changes

Monitor the file for changes. If the file is changed, run a script to copy that file to other servers using scp or rsync. i am looking for automatic script to copy the changes in the file from local ...
1
vote
1answer
30 views

My backup_system.sh file didn't run under crontab

So i created a script used to backup system, i tested and it worked. Here's the script: #!/bin/bash backup_files="/home /var/spool/mail /etc /root /boot /opt" dest="/mnt/backup" day=$(date +%F) ...
1
vote
1answer
43 views

grepping particular matrix and printing it in single row

I have one file that contains key words word1 and word2 and under word2 there is a matrix as file.dat position1: [ 0.0000000, 0.0000000, 0.0000000 ] word1: 0.0000000 band: - # 1 ...
9
votes
1answer
626 views

Why do some Linux shell scripts use exec to run commands? [duplicate]

In a Linux bash script such as: exec /usr/lib/4.5/mono-service.exe ./AudioVideoRecorder.exe "$@" , why do I have to exec the command and not just run it without the exec part?
0
votes
3answers
37 views

Combining several text files into a single csv [closed]

Input files: File: Article1.txt: paragraph1 It is a long established fact that a reader will...... paragraph2 It is a long established fact that a reader will...... paragraph3 It is a long ...
34
votes
13answers
3k views

What is a fast command line way to switch between multiple directories for system administration?

What is a fast command line way to switch between multiple directories for system administration? I mean, I can use pushd . and popd to toggle, but what if I want to store multiples and cycle through ...
0
votes
1answer
50 views

Bash script to add or subtract two numbers from user input

I am very new to Linux and am taking a course in it. Very excited to learn more. I am working on a script that asks user for two numbers, then asks whether user wants to add or subtract. I failed the ...
0
votes
1answer
41 views

better multiple replace with curly braces

for a single replace the curly brace works fine but i cant find a solution for multiple replace where is the trick ? or its not possible for multiple replace i use sed and for single the curly braces ...
-1
votes
2answers
30 views

Execute vim in a loop [closed]

I am writing a script which will let the user edit more than 1 files. I'm trying to launch vim for every file. I've tried putting the filenames in an array and iterate over every element of array and ...
1
vote
0answers
30 views

How to evaluate commands on the given node of cluster by using plink?

Despite plink (putty link, which provides remote evaluation of commands on remote cluster by using ssh) is Windows application, I hope that You will help me in this question. I have the remote ...
1
vote
2answers
22 views

Error while counting characters in a file

I have a source code to find a number of words and characters in a file: #!/bin/bash w=0 cc=0 for i in `cat $1` do j=$i echo $j w=$(($w+1)) c=`expr $j:'.*'` cc=$(($cc+$c)) done echo "no of characters"...
0
votes
2answers
36 views

Convert bash loop index to floating-point

I need to use the index i in a loop such as for i in {0..10..5} in a floating-point calculation. What is the simplest way to convert i to floating-point? Variations on i=$(bc -l <<< "scale=7;...
5
votes
2answers
242 views

Using expr, $(()), (())

In shell script we can substitute expr $a*$b with $(($a+$b)). But why not just with (($a+$b)), because in any resource it is written that (()) is for integer computation. So we use $(()) when ...