Questions specific to GNU’s Bourne Again SHell, as opposed to other Bourne/POSIX shells. For questions about Unix shells in general, use the /shell tag instead.

learn more… | top users | synonyms

2
votes
1answer
16 views

How do I bring HEREDOC text into a shell script variable?

I'm trying to bring HEREDOC text into a shell script variable. I tried like so: #!/bin/sh NEWLINE=" " read_heredoc2() { while IFS="$NEWLINE" read -r read_heredoc_line; do echo "${...
0
votes
2answers
13 views

Trigger a non-zero exit code when I break out of a loop

I'd like to run a series of tasks but stop should any of them fail, hence I've written (something like): for task in [TASKS]; do process "$task" || break commit "$task" done This works fine, but ...
0
votes
1answer
18 views

bash script error. error on the part of EOF, there must be some files that enter or missing files, anyone can help? thank [on hold]

#!/bin/bash # Info # --- # script can run with the domain as a command line input # `sudo ./nginx_domain.sh my_domain.com` or without and # the script will prompt the user for input #config ...
2
votes
1answer
16 views

How to keep idle session from exiting

I'm working remotely on a new CentOS 7 VM. I have screen running with several open sessions. I'm finding that if I leave one of the sessions idle for awhile, then try to come back to it, it's gone. ...
0
votes
1answer
16 views

Implement inclusion of another file into a stream (read from stdin)

Background I'm facing the following problem: I insist on using m4_include([some/file.m4]) in my configure.ac file, where some/file.m4 then contains patterns like 'AC_INIT' and 'LT_INIT' that are ...
0
votes
1answer
18 views

Search For Different File Name in Loop

I want to do search through a bunch of directories to find missing files. The format of the directories and files is YYYY/MM/file_name_YYYYMMDD.csv. So what I want to do is something like: for date ...
-3
votes
1answer
27 views

What's wrong with getopts or grep here

#!/bin/bash #return codes: STATE_OK=0 STATE_WARNING=1 STATE_CRITICAL=2 STATE_UNKNOWN=3 if [ $# -lt 4 ] then echo "UNKNOWN: Please, Pass Enough Parameters" ...
0
votes
1answer
29 views

How does one parse ${!i} (and what does it mean)?

I came across ${!i} in the body of a for-loop of the form for ((i=$#; i>0; i--)); do # ... if <SOME_TEST>; then # ... accumulator="${!i}:${accumulator}" # ... ...
7
votes
2answers
381 views

shell scripting addition

Suppose two numbers are stored in two different files. a.txt and b.txt. Each number say large enough(more than 30 digit) not to be supported by data types. So how to add them in bash shell.?
1
vote
0answers
23 views

How to set bash readline to vi mode automatically upon login to a system?

My team is responsible for thousands of Linux/Unix machines, so naturally the root account is "shared" amongst the admins. I prefer vi mode, others prefer emacs mode. How can I set bash's readline ...
0
votes
1answer
29 views

Accuracy of -newer test

It appears that the-newer test is not quite as accurate as I would like. Using ls -lt I get the correct sort order: -rw-r--r--@ 1 p staff 48 Jan 26 14:42 foo.gdb -rw-r--r--@ 1 p staff 328971 ...
2
votes
2answers
98 views

Bash test: what does “=~” do?

#!/bin/bash INT=-5 if [[ "$INT" =~ ^-?[0-9]+$ ]]; then echo "INT is an integer." else echo "INT is not an integer." >&2 exit 1 fi What does the leading ~ do in the starting regular ...
0
votes
0answers
20 views

How to get data in correct order from terminal using Expect

I'm using Expect to automatize the following tasks in a switch: log in via telnet ask for neighbors (devices conected directly to the switch) save neighbors information into a text file. Check if ...
-1
votes
1answer
16 views

Installing cyberoam client on Kali Linux(Bash says no file or directory found)

I can see the file when I invoke ls, but when I try to access the file, BASH exits with the following error. bash: ./crclient: No such file or directory
1
vote
2answers
87 views

Bash: Show the contents of a text file, with every occurrence of a word highlighted [duplicate]

How can I show the contents of a text file, with every occurrence of a word highlighted?

15 30 50 per page