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

learn more… | top users | synonyms (2)

2
votes
2answers
21 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
67 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
165 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
213 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
47 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
14 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
1k 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
47 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
43 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
56 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
42 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
38 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
31 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
44 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
754 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
38 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
61 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
44 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
36 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
35 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
23 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
40 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
248 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 ...
1
vote
1answer
45 views

Need to filter the data on the basis of two column having many to one relationship using awk

I have a big file having 50s columns and 100K of rows delimited by |. Now $2(col 2) has multiple type of $1(col 1) value which means col 2 will be repeated. So I have sorted the file. I need now to ...
4
votes
2answers
56 views

Fix array of incomplete links

I'm writing a bash script that will find links in a page. It downloads the source code from a page and finds links in a tags and stores them into an array, $links. The problem though is that some ...
2
votes
1answer
27 views

Finding change in shared object through bash

Here's my case- I have a package named say foo-1.2.3. I want to know which package it installs. So, I install it in a fakeroot approach and make a list of all files it install in a file called FILES ...
2
votes
1answer
39 views

Source of “gsed: can't read : No such file or directory”?

I have a Bash script that performs a simple substitution on OS X. Here's the reduced case: mkdir vs2005-dynamic cp cryptdll.vcproj cryptest.sln cryptest.vcproj cryptlib.vcproj dlltest.vcproj vs2005-...
2
votes
2answers
90 views

search contents of files that are packed in a zip file

For my school project i have to create a script that allows you to search the contents of files that are packed in a zip file. You can give a "search string" with the script, followed by one or more ...
10
votes
4answers
431 views

Run command after a certain length of time has elapsed?

If I'm executing a long process, is there any way I can execute some time-based commands? For example, I'm running a really long process which runs for roughly 10 minutes. After 5 minutes, I would ...
1
vote
1answer
43 views

Move files several directories up for several directories with similar layout

I have a directory with the following layout (the layout in Directory 1 is repeated in every other Directory <num>): Parent directory Directory 1 some directory another ...
2
votes
0answers
28 views

Shell script which runs mono_service.exe as a background task

When I start an Ubuntu Linux 16.04 process with /usr/lib/4.5/mono_service.exe AudioRecorder.exe it returns right way. But, when I write a bash shell script with one line: exec /usr/lib/4.5/...
1
vote
1answer
90 views

How to compare a program's version in a shell script?

Suppose I want to compare gcc version to see whether the system has the minimum version installed or not. To check the gcc version, I executed the following gcc --version | head -n1 | cut -d" " -f4 ...
-1
votes
1answer
50 views

Sub Directories in sub directory using loop

On my CentOS machine, I need to create a main directory inside which I will have a few sub directories and, inside them, some subsubdirectories. Something like: main_directory->sub1,sub2,sb3.. ...
1
vote
1answer
18 views

whiptail require three numbers before continuing

I have this whiptail form that prompts for user input. Is there a way to force someone to enter three numbers, before allowing him to continue? NUMBERS=$(whiptail --inputbox "Enter three numbers only"...
1
vote
1answer
37 views

`sudo -u user script` does not even have access to /bin/sleep

When running the script bla with sudo -u otheruser ./bla I get an output indicating that this script is run such that no external commands are available: otheruser ./bla: line 3: /bin/sleep: ...
0
votes
1answer
34 views

How to execute scripts in a parent-child behavior in bash?

Suppose I have two scripts named parent.sh and child.sh. The parent.sh script contains bash child.sh line and the child.sh script contains echo "This is the child script". Now, if the user executes ...
2
votes
2answers
113 views

what is the difference between “./command” and “bash command”

I have simple bash script file, it contains only one line: rvm gemset use --create 2.0.0@PRJ_NAME If I run this script with: ./scriptname.sh I get a well-known error message from RVM RVM is not ...
-4
votes
1answer
34 views

Create file with date and information

I want to create a file in a shell script. The file's name should be: MyFile_datetoday.dat Where datetoday is today's date in YYYYMMDD format. The contents of the file should be: nameofmyfile;...
2
votes
2answers
93 views

Change directory without using 'cd' [closed]

I have a list of files with their paths in a text file. And I want to copy these files, mentioned in list, to another directory with their parent folders tree. Also my shell-script to copy these files ...
0
votes
0answers
75 views

Count and compare files in Linux

I want to just compare the number of lines in two files. Below is the list of names of files. One file contains names/location of fastq files; the other file contains names/location of bam files. ...
0
votes
2answers
31 views

troubles working on a script with $# and a loop

i have the following script: #!/bin/bash for ((i=1; i<=$#; i++)); do if [ ! -d $i ] then echo $i its not a directory >> file.txt else ...
0
votes
2answers
47 views

simple for loop script to build out ipv6 subnet

I am trying to use nmap to scan a /119 IPv6 network. (512 addresses). Before I do this I want to generate a file that will populate all of the ip addresses in that range. The network info is as ...
1
vote
1answer
16 views

Alias folder of executables with prepended keyword

I have several executable files in a folder /opt/chefdk/embedded/bin/. Examples are ruby bundler chef. Ideally I want to be able to run these files by simply prepending the keyword chef-$1 or chef $...
0
votes
2answers
64 views

Create blinking text with echo and escape characters [duplicate]

I have learned about formatting options used in shell scripting, which go like this: \033[37:40mAnyText\033[0m Now I want to echo some text like this: echo -e "SomeText \033[5;31;47mMoreText\033[...
-3
votes
3answers
55 views

Sorting not seeming to work [closed]

I am currently writing a webcrawl bot. It generates a list of URLs, and I need it to remove duplicates, and sort the lines alphabetically. My code looks like this: #! /bin/bash URL="google.com" while ...
11
votes
3answers
774 views

How do you remove dot character from string without calling sed or awk again?

I have a file called hostlist.txt that contains text like this: host1.mydomain.com host2.mydomain.com anotherhost www.mydomain.com login.mydomain.com somehost host3.mydomain.com I have the ...