Questions about bash only, as opposed to other Bourne/POSIX shells. For all Bourne/POSIX-style shells, use the /shell tag instead.

learn more… | top users | synonyms

0
votes
0answers
16 views

Resetting Terminal colors on logout

I am using these setting in my .bashrc to make the terminal colors match the ones in the solarized palette echo -en "\e]PB657b83" # S_base00 echo -en "\e]PA586e75" # S_base01 echo -en "\e]P0073642" # ...
3
votes
1answer
56 views

Help me understand this command

I found this bash command that creates a directory tree in your console window. I find it quite useful, but I don't really understand how all of the special charectors work. Could someone help break ...
4
votes
4answers
80 views

Using jq to extract values and format in CSV

I have the below json file: { "data": [ { "displayName": "First Name", "rank": 1, "value": "VALUE" }, { "displayName": "Last Name", "rank": 2, ...
-2
votes
0answers
29 views

why is my delete function not working [on hold]

#!/bin/bash record() { inodeVar=$(ls -i $1 | cut -d " " -f1) mv $1 $1"_"$inodeVar } Restore() { echo $1 >> ~/.restore.info } # Check whether RMCFG is null and creates bin ...
0
votes
0answers
21 views

route -n gives output “route: fscanf”

If I boot my system and no interface has an IP address I get the above output. However if I give an interface an IP, even if I remove it again, this will disappear. Why does this happen? Is it that ...
1
vote
1answer
18 views

Specifiy Unix TimeStamp Range in Parameter

I am launching a mrjob in bash and need to pass in as parameters a range of gz files which have unix time stamps in them as: filename_9127381923.gz. How to do this in the simplest possible way? I can ...
4
votes
1answer
242 views

Why does “cat /tmp/out1 > /tmp/in2 &” appear as “bash” with the “ps” command?

Consider: mkfifo /tmp/out1 mkfifo /tmp/in2 cat /tmp/out1 > /tmp/in2 & When I run ps It appears as "bash" in the CMD section. Why?
2
votes
1answer
18 views

PHP CLI and Bash - change behaviour of PHP keyword

Our hosting providers have installed 3 versions of PHP onto our linux box and when I SSH into it the command php points to use/bin/php which is version 5.2, the command php-5.4 points to ...
4
votes
1answer
64 views

While command not found and syntax error near unexpected token [on hold]

I am trying to write a shell script that takes a string input from a user, asks for a file name and reports whether that string is present in the file. Below is my current script. #!/bin/bash while ...
2
votes
1answer
29 views

inotifywait - get old and new file name when renaming

I'm looking for a reliable way to detect renaming of files and get both old and new file names. This is what I have so far: COUNTER=0; inotifywait -m --format '%f' -e moved_from,moved_to ./ | while ...
3
votes
2answers
34 views

Help with iterating fieldA in CSV file, where fieldB has specified value

I've been trying to setup a script to run on gitbash, to process a CSV file so each record that has a specific value, the last field is changed from empty ("") to a value that iterates from 1 to 16. ...
2
votes
1answer
28 views

Bash script to verify that an rpm is at least at a given version

I need to write a script to verify that an RPM is at least a given version in Linux. QUESTION 1: How can I get the RPM version in a variable $RPM_VERSION, so that it contains the version all the way ...
2
votes
1answer
19 views

How do I stop screen from clobbering my titles?

I am using bash and GNU screen on centos7. I notice that if I ssh to another server, change the title (via ctrl+a+A), and log out of the server that my new title gets overwritten by USER@HOST:~. How ...
0
votes
0answers
72 views

How I can modify a sh command? [on hold]

I need to modify the code for one of the sh commands. For example: Add a one line of code that prints your name when a command is executed by a user on the shell. I want editing of source code for ...
1
vote
1answer
24 views

How to check PIPESTATUS equivalent during PROMPT_COMMAND execution?

I have a custom $PROMPT_COMMAND in bash that logs the last executed command and its return code. I was using $? for the latter happily until I realized that for piped commands this was insufficient. I ...
1
vote
2answers
34 views

Control which process gets cancelled by Ctrl+C

I have a live CD that boots into Linux and runs a small Bash script. The script searches for and runs a second program (which is usually a compiled C++ binary). You're supposed to be able to abort ...
0
votes
4answers
35 views

How to save in a variable the convert from decimal to binary without use an echo

I've been trying to save in a variable the value of the convert of a number from decimal to binary, like this: num1=10 echo "obase=2;$num1" | bc | tee -a register.txt but I don't want to show it ...
1
vote
1answer
35 views

Pipes & redirection binding precedence with disjuncts, conjuncts etc?

I know of the relative binding precedence of operators ‘;’, ‘&’, ‘&&’, or ‘||’ http://www.gnu.org/software/bash/manual/bashref.html#Lists but when pipes come into the picture along with ...
0
votes
1answer
31 views

How can I write a script which updates a text file?

I have made this script #PACKAGES.TXT array2=( `find . -type f -iname *t?z|awk '{print $1}'|cut -d / -f 3` ) funzioneZ() { echo -e " PACKAGE NAME: $i " } array3=( `find . -type f -iname *t?z|awk ...
1
vote
3answers
42 views

How Long do the Contents of the .bash_history File Last?

How can I modify the contents of my bash_history file? What values or variables control how long the history lasts? Are there any other things I can change to provide finer control of my BASH ...
0
votes
2answers
45 views

How can I use netcat (nc) for chat client server model?

enter code hereI am trying to write a daemon using bash. I will enter my partners IP address and the connection will start using nc partner_ip 2015, likewise on the server I will start the connection ...
0
votes
1answer
33 views

Howto adapt this bash construct to a sh valid construct

On converting some bash scripts to a platform where only /bin/sh is available i'm stumble about this bash construct: #!/bin/sh RSTPD=/sbin/rstpd RSTPCTL=/sbin/rstpctl RSTP=0 ...
3
votes
1answer
36 views

Is checking for exit status other than 0 after a `command || return` unreachable?

I am a shell script beginner and found the following patch of code: function some_fun() { #[...] [ -d ${MKAPP_BUILDDIR}/tmp ] || mkdir ${MKAPP_BUILDDIR}/tmp || return 1 if [ $? -ne 0 ]; ...
0
votes
1answer
35 views

Perl/awk/bash: multiply and sum values putting values inline instead original text [on hold]

I have a text like this: ;--------------------------------------- JOURNEY_ARRAY_01 .BYTE <JOURNEY_00 .BYTE <JOURNEY_01 ;--------------------------------------- JOURNEY_ARRAY_03 ...
0
votes
0answers
48 views

Sometimes command with many pipes makes empty output [on hold]

I am wondering what causes this problem and finding the solution (except for temporary file). When I execute certain code CHIMP+testis_uniq_expression.out file with like this, it makes empty output. ...
2
votes
2answers
46 views

An alias for a command to kill stopped jobs

I wanted to add an alias to my .bashrc so that I could kill all stopped jobs with a command like kill_stopped. I am aware that kill `jobs -p` can be used to accomplish this but I'd rather have an ...
1
vote
1answer
22 views

several virtual profiles for the same user

Many times there are several "identities" which one user uses: for work, open-source, academia etc., all require different ssh keys, editor configurations, git configs etc. I was wondering if there ...
1
vote
3answers
86 views

How to sum match numbers

I'm new at scripting, and need some help. Will appreciate your answers. I got this assignment, which is to find the sum of all five-digit numbers (in the range 10000 - 99999) containing exactly two ...
9
votes
4answers
412 views

Regular expression using \\ vs using \

Why does grep e\\.g\\. <<< "this is an e.g. wow" and grep e\.g\. <<< "this is an e.g. wow" do the same thing? If I add a third slash, it also has the same result. BUT, once I ...
0
votes
2answers
57 views

Why does this Shell script fail as cron job [on hold]

I have the following in a shell script, when I run this script it works but when I put this as a cron job it does not work(nothing happens!). How come? script #!/bin/bash ...
3
votes
1answer
20 views

Is there a way to flatten a .pdf image from the command line?

In GIMP, I can import a .pdf, and use the GUI to flatten it (if it was made with many layers) by selecting "Flatten Image" in the "Image" dropdown menu. I can then export the .pdf with a new ...
-1
votes
0answers
34 views

Practical usage of pushd, popd, man, less, and cat in bash [closed]

So i am learning more advanced usages of bash/cmdline due to work teaching me some programming and im trying to wrap my head around some of the following bash cmd's and their purposes. I have been ...
1
vote
3answers
64 views

How to align a table of display nicely

I am trying to create a script that act as a ps command with it's own properties that I want to display. Say this is how processes would look like in ps command: sas 24431 1 0 Oct10 ? ...
1
vote
1answer
41 views

Append to PATH-like variable without creating leading colon if unset

I need to append a directory to PKG_CONFIG_PATH. Normally, I would use the standard export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:$(pyenv prefix)/lib/pkgconfig but PKG_CONFIG_PATH has not been ...
7
votes
3answers
262 views

How can a Bash script tell how it was run?

I have a Bash script I was trying to make to help me run a rather complex command with small changes that it would ask me about through echo and read. I have found solutions to force it to run a ...
0
votes
1answer
49 views

reading file using for, while - behavior

Consider the below scenario 2 vms - 192.168.229.131, 192.168.229.132 Both the vms has it's ip as 192.168.229.151 & 192.168.229.152 in it's /etc/hosts file Say there are around 50 vms like i ...
3
votes
1answer
105 views

What are the bash shell length limitations for here-docs?

What are the length limitations for using here-docs as part of bash command lines? I am finding that short here-docs work fine, but when they get longer there is some point or structure after which ...
1
vote
3answers
53 views

Random character generation - with random output!

This is what crunch can generate: [user@localhost ~] crunch 3 3 ab Crunch will now generate the following amount of data: 32 bytes 0 MB 0 GB 0 TB 0 PB Crunch will now generate the following number ...
1
vote
0answers
42 views

Why is the order of expansions as it is in bash? [closed]

From Bash Reference Manual: The order of expansions is: brace expansion, tilde expansion, parameter, variable, and arithmetic expansion and command substitution (done in a left-to-right ...
2
votes
2answers
46 views

Environment variable not expanded inside the command line argument

I have a file user-pid.out2 which has "usernumber" and "process id" as two columns. based on usernumber I want to find corresponding process id. the first two lines below does not show the output ...
1
vote
2answers
52 views

How to perform command substitution before brace expansion

I would like to perform command substitution before brace expansion, but couldn't: $ ls {$(seq -s , 13 20)}.pdf ls: cannot access {13,14,15,16,17,18,19,20}.pdf: No such file or directory How can I? ...
-1
votes
1answer
51 views

Is it possible to run two commands at the same time in a shell script?

I know that on the command line I can use & to run a command in the background. But I'm wondering if I can do it in a script. I have a script like this: date_stamp=$(date +"%Y-%m-%d" ...
0
votes
1answer
50 views

Bash error: “[y command not found” [duplicate]

I am trying to get this script to function correctly but I get ./passmark.sh line 7: [y command not found. Here is my script #!/bin/bash # A simple script to ask a user for a pass mark and then ...
1
vote
1answer
48 views

count matches and mismatches group by

Please help with a shell script of the following. I need count number of consistent variables in each lane (col1) across samples (col2). For example, since all the values (col4) of lane1 variable 1 ...
1
vote
1answer
33 views

How can I maintain line breaks in body text with mailx when sending attachments?

I have a script that emails the text of a log file as the body of the email. That log file has some blank lines between lines of text for readability. When I use the following line in the script, ...
1
vote
1answer
12 views

Send multiple files to bash script via Dolphin

I would like to process photos by sending them from Dolphin to bash script with "Open with" feature. But it runs individual instance of the program for each file instead of sending all files to one ...
1
vote
3answers
36 views

How to transpose command line arguments with emacs keybindings?

Using Bash, with emacs keybindings set, the transpose-words keybinding (M-t) doesn't transpose arguments, but "words" (by its own definition of words). So if I have this: vimdiff ...
3
votes
2answers
86 views

How can a bash script write its standard output from within a pipeline? [duplicate]

I have a bash script that calls a function. The function, amongst other things, executes a pipeline that sinks its output. To simplify it, here is a contrived example: #!/bin/bash func() { ls "$@" ...
1
vote
1answer
35 views

How do I get the exit code of a process, which runs through wine

I'm trying to run a Windows executable via wine. When I first try to run it never runs, but when I attempt to do it again, the program runs. I'd like to make a script to run the program, here's the ...
0
votes
0answers
15 views

How does `Alt` decide which strings is a word in bash? [closed]

I can use Alt+f, Alt+b and a series of other Alt command to doing things with word. But the concept word is vague for me. From my experience, . , _ are valid separators for a word, meanwhile ' isn't, ...