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

learn more… | top users | synonyms (2)

-4
votes
1answer
21 views

Bash - Print lines containing at least all vowels in any order but no consecutives [solved]

The problem is to write a script that takes a file as argument and prints all the lines that contain -at least- all the vowels , -regardless of ordering-, but with [no two same consecutive vowels]. e....
0
votes
0answers
15 views

Delete command in Unix SQL loader [on hold]

When I use the delete statement in shell script, it deletes the record but in log it also shows as delete not found. Please respond if you have any idea on this. Below is sample statement I am using ...
-2
votes
0answers
32 views

script to add any 3 numbers in a file and print if it return 1000

I have file which contain 100 random numbers separated by newlines. I need to check if there are 3 numbers in that file which sums to a total of 1000. e.g. $ cat number.txt 500 100 50 50 400 The ...
-4
votes
1answer
29 views

Squaring all numbers in a file

Please, can someone share with me, or show me the script for Linux command to read from a file until EOF and compute the square of all numbers read. The result of this computation must be stored in an ...
1
vote
0answers
8 views

Shell script to grab one or many Wistia videos

What would be the best way to come up with a shell script that grabs one or many Wistia videos? There's plenty of proof-of-concepts out there for downloading YouTube videos via a shell script (i.e.: ...
2
votes
1answer
30 views

How to suppress echo of buggy read function

I'm trying to capture a key press in a shell script (e.g. using read) and not to echo it. The three methods I found were stty -echo, the -s switch and stream redirection. However, on macOS, which ...
4
votes
2answers
48 views

Compose string of IPs using bash command line

I have a command that returns the following: id1="172" id2="17" id3="136" id4="5" id5="0" /> id1="172" id2="17" id3="128" id4="2" id5="0" /> id1="172" id2="17" id3="128" id4="4" id5="0" />...
2
votes
2answers
33 views

Get only the size of a mounted filesystem

I want to get only the total size of a mounted filesystem. But the catch is that I only know about the mount point. So, I thought of using the df command. To get the size of this mounted filesystem, ...
0
votes
2answers
30 views

Generating strings of words with space delimiters from cut statement

I am new to bash. When I run the following command: grep "type" /root/myFile | cut-d'=' -f2 I get the following: 102 304 503 442 I want to store the contents of the first command into a ...
0
votes
1answer
43 views

how to write own shell that works with ssh [on hold]

I tried several tutorials I modified usermod -s shell path_to_binary username it does not work thru winscp, but works if use from Ubuntu terminal I want to own shell, where I can control over ...
0
votes
0answers
8 views

Setting up SMTP-AUTH & people soft in Postfix

configured SMTP server in people soft -post fix for gmail authentication is not picking up correct sender name- configured in peopesoft- using default sender name as smtp-people soft@org.com this has ...
0
votes
0answers
28 views

How can I customize output of a command? [on hold]

One of my friends asked me how to customize the output of a command & I thought a bit but I can't find an acceptable answer. ( For example adding * at the start of every output of the find ...
1
vote
2answers
28 views

GNU Parallel and sshpass with server list in a loop

With this loop we sequential update on all servers (server list = consul members | grep awk {'print $2'} | cut -d ":" -f1) the package consul. for i in $(consul members | grep awk {'print $2'} | cut -...
0
votes
3answers
38 views

How to pick oldest file in a folder from directory [duplicate]

I had n number of files are there in my ../in/ directory. From those files I want the oldest file to process and send it to the ../complete/ directory. The remaining files are sent to the ../error/ ...
1
vote
1answer
34 views

Extracting from Logs

Actual logs are: 2016-06-19 22:08:09 [213917] 1bEgCe-000tZR-E9 ** saadia@aol.com (fahad@manakintextiles.com) <fahad@manakintextiles.com> F=<james@designplus.com> P=<james@designplus....
3
votes
1answer
36 views

Sort files into folders, depending on filetype

I have about 2.8TB (yes, terabytes) of data I have recovered, this will be scanned for duplicates, the machine these files reside on is quite old and only has 2GB of memory (works fine for LVM, ...
3
votes
0answers
57 views

wait bash-builtin burns a CPU at 100 percent

Occurs at least on GNU bash version 4.3.42 x86_64 && GNU bash version 4.3.11 x86_64 I use sleep & wait $! instead of a simple sleep for getting an interruptible sleep by a signal (as ...
0
votes
0answers
39 views

Bash script: read file for strings and output those lines to new .txt file, what's the best route?

I have a spreadsheet(.xlsx) that I need to scan for 5 strings from only 1 column, then I need to output those rows to a new text file. It has to be a bash script, i.e. no perl/python/ruby, and from ...
1
vote
1answer
49 views

insert the content between the matching pattern in shell script

I want to insert the content between the matching pattern in shell For example : file called input.txt : var a = [ ] file called output.txt : 1152 1185 1185 I want to insert the values ...
3
votes
2answers
164 views

what is $$ in bash? [duplicate]

there is a script I evolved with it, it has line of command like below : mytemp=`echo ${sourcedir}|awk -F/ '{printf "/%s/tmp",$2}'`/`basename $0`-$1.$$ at the last of the command we see $$ that ...
0
votes
1answer
39 views

when i used sed -n ,why this err about sed -n ' $j,4800p' [duplicate]

LINEnum=$(grep -nr "#32" IM_DlCtrlRef.txt | cut -d : -f 1) for j in $LINEnum do echo $j sed -n '$j,4800p' IM_DlCtrlRef.txt >> IM_DlCtrlRef_bak for insertl in {1..4} do ...
0
votes
2answers
40 views

Can I use a shebang to have a file source itself into current bash environment?

I have a growing collection of scripts which should be sourced, not run. At the moment they have the shebang #! /bin/cat but I would prefer the have them be sourced into bash when run, in the same ...
-6
votes
0answers
32 views

Write a Shell Script to generate a report named “Report_DDMMYYYY_HHMMSS.log” [on hold]

Write a Shell Script to generate a report named "DD_MM_YYYY_HH_MM_SS.log"which performs the following operations: 1) ** Display the number of files present in the given directory (Directory name ...
0
votes
2answers
37 views

Skip catching errors in bash

I have a script which compile a program. This program first compiles the source code using configure && make commands, then runs some tests using make test. This script also uses set -e to ...
-1
votes
1answer
51 views

Syntax error at line 18 : `<<' is not matched

Here is my script #!/bin/bash stty intr ^C erase ^H kill ^U p_id=`ps -ef|grep iucmh|grep iuc|grep MSC015|grep START|awk -F" " '{print $2}'` vLogin=`echo "iucmh/iucmh123@4s_MH"` if [ -z "$p_id" ]; ...
2
votes
2answers
44 views

Command behavior is different when executed by an other user (via su -c)

I want to kill every processes who match a specific chain. Here is my script, which works pretty well: echo `ps aux | grep verySpecificChain | grep -v grep | /usr/bin/awk '{ print $2 }'` | xargs kill ...
2
votes
1answer
31 views

shell script echo text name in for looping multiple texts

I am trying to do this text1="word1 word2 word3" text2="word4 word5" text1="word6 word7 word8" for var in $text1 $text2 $text3 do echo $var" in "(__?__) done expected output word1 in text1 ...
0
votes
1answer
52 views

Using multiple sed commands for text manipulation

I have a bash file, in which I would like to make several changes. sed -i 's/ / /g' testfile sed -i -e 's/#[a-z]$//' -e '/^$/d' testfile sed -i 's/ *$//' testfile sed '/##=/ r header' ...
0
votes
2answers
42 views

How to add a column of numbers to a array data file

I have a data file with two columns of numbers: input file 4.182 4.1843 4.184 4.2648 4.2281 4.0819 4.2204 4.1676 4.0482 4.1683 4.0156 4.2895 4.4504 5.2369 4.3776 4.4979 4.3797 4.1372 4....
0
votes
1answer
22 views

How to multiply two columns in a file by a constant number

I have a file like this. input data 4.2394 4.4569 4.2427 4.1011 4.2879 4.1237 4.2106 4.4844 4.2373 4.1071 4.1322 4.0502 4.3103 4.4255 4.4342 4.5262 I need to multiply each element by a constant ...
0
votes
1answer
31 views

Using http remote MD5 hash

I would like to use the md5sums function of pkgbuild without keeping track of new hashsum at each update, and just change the pkgver variable to build a new version of my package. md5 are available ...
0
votes
3answers
77 views

How to do a loop to execute many files

I have a script which function like this for one file. ./script 0001g.log > output for two or more files, like this ./script 0001g.log 0002g.log 0003g.log > output The script take one ...
0
votes
1answer
23 views

Run script simulatneously with loading desktop

I am running Kali 2, and have a script that I want to run on startup. Right now, I have the script in my profile.d directory, but it takes too long to execute. The effect is that after I login, the ...
0
votes
1answer
56 views

cat specific line range from /etc/hosts to dialog box

I need help with dialog box in bash. I like to list, for example all Ethernet switches from /etc/hosts and show them inside dialog box. After that I would like to connect selected switch from the ...
3
votes
2answers
57 views

Can you tell if a file has been renamed?

Many tools out there for syncing files aren't quite right for syncing you're home directory. Because of this, and to learn Ruby, I've been working on my own sync tool. An issue I've encountered, ...
1
vote
2answers
40 views

Defer variable expansion to subshell

My service uses environment variables extensively for configuration (mostly because it's really easy to inject those into a Docker container). I also have some maintenance scripts that I can run ...
2
votes
2answers
61 views

How to refer to multiple files from a directory to one command

I have a command that needs to take multiple input files, which are originally from one directory and have certain file name patterns. For example: In directory /home/mydir/ I have files: A.dat B....
1
vote
0answers
23 views

Avoid starvation using flock with 2 process with write and read lock

I have two scripts let's call them script1 and script2. The script1 is scheduled every 2 minutes and it takes 4 minutes to execute the script2 is scheduled every 30 minutes and it takes 4 minutes to ...
2
votes
1answer
43 views

One of several file-append redirections of “python --version” is repeatably 'overlooked' by bash, but the others aren't [closed]

Why is bash consistently passing one, specific redirected output from python --version to the console rather than appending to file, while every other output is redirected properly? I am developing a ...
1
vote
0answers
25 views

Bash check if firefox use internet

I want to check how much internet use Firefox with a shell script. Here I found good examples to see performances. #!/bin/sh free -m | awk 'NR==2{printf "Memory Usage: %s/%sMB (%.2f%%)\n", $3,$2,$3*...
0
votes
0answers
53 views

Extract text above exception line in output [closed]

I have the following error output from a program: 2016-06-20 02:09:28,264 Mbr10063a cOqZeJiM BaseAction.java:getAlerts:618 ERROR [AlertAction] Could not open JDBC Connection for transaction; 2016-06-...
0
votes
0answers
25 views

Shell syntax var=${var:-$var2/file} [duplicate]

I came across the following syntax while working with some shell scripts. I am unable to understand what it does and I am not sure what should I search to get right documentation for this var=${var:-$...
23
votes
1answer
2k views

If “bash <file>” works, why is “source <file>” throwing an error?

I have the following script: #!/bin/bash set -x if :; then echo a fi If I run bash /tmp/file, a is echoed, but if I run source /tmp/file, I get: bash: /tmp/test: line 6: syntax error: ...
1
vote
3answers
70 views

Extract filename from another filename

I receive notification files for different files. I want to extract the filename from these notification files which I would use in another process. The first 4 strings of the notification file will ...
0
votes
0answers
46 views

A script to remove and put menu on Xfce

I encountered a bug in Xfce that if I move an program icon on panel, the applications menu disappears. I found the solution that if I remove the menu and then put it back, the menu won't disappear ...
0
votes
1answer
73 views

Simple if command not working in csh script

I have made a basic shell script using IF command as a purpose to help myself as I am a beginner. Problem is that when I execute this script using source overspeed (after giving myself execute ...
1
vote
2answers
132 views

Remove leading whitespace before possible shebang

I have a large collection of non-binary files in one place. Some of them have shebangs and of those some have (for some inexplicably reasons) whitespaces in front of the shebangs. This includes empty ...
0
votes
1answer
137 views

Check if date is n years old

I have a variable $date with format yyyy-mm-dd and I would like to check if it is exactly 1 year, 2 years (and so on) old. That's what I tried so far: dates=$(echo $date | cut -c6-10) todays=$(date +...
0
votes
0answers
33 views

How to transfer a big file simultaneously to several machines remotely? [duplicate]

I have launched 10 instances on a cloud service, and these are the steps that I want to do in parallel (simultaneously): 1) Copy a big input text file to each machine 2) Run a java program called ...
2
votes
1answer
117 views

How do I get bash to give a relevant error for a file with windows line-endings?

Suppose I have the following shell script: #!/bin/bash \n echo "Hello World" \n Running it gives Hello world. Now suppose I have the following shell script #!/bin/bash \r\n echo "Hello world" \...