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

2
votes
2answers
27 views

Can I ignore __pycache__ directories in bash-completion and grep?

I've ignored __pycache__ in my git repos and in vi's wildmenu. The last place these directories pollute my workflow is when recursively grepping through project files and when using tab ...
1
vote
4answers
59 views

bash dynamic (variable) variable names

I want to dynamically create a sequence of strings by manipulate an array of elements and create some arithmetic procedure. for name in FIRST SECOND THIRD FOURTH FIFTH; do $name = $(( $6 + 1 )) ...
1
vote
2answers
55 views

Odd syntax for ssh and bash to run command

I'm pretty new to shell/bash scripting and I'm writing a script on OSX to automate some rather tedious efforts. I'm trying to run a portion of my script on a remote host using ssh. There's a common ...
1
vote
1answer
56 views

How to execute a for loop in bash as a string

I need to execute a loop as a string. This: bash -c "for l in $(/bin/ls /dir1); do /bin/ln -sf $l /dir2/; done" Gives an error: /bin/bash: -c: line 1: syntax error near unexpected token `file1' ...
1
vote
2answers
24 views

Bash not sourcing ~/.bash_profile on os x

I just got this really wierd poblem. When I start bash, I get these two lines: -bash: fasd: kommandot finns inte -bash: brew: kommandot finns inte "kommandot finns inte" means command does not ...
2
votes
1answer
40 views

Bash do action as nobody and nogroup?

I have a log file that was created by nobody:nogroup, which is activity being logged to, I wanted to emulate adding a message to that log file. My first though was to: $ sudo su nobody This account ...
5
votes
2answers
45 views

Bash wrapper that will format the output of another program

Is there a wrapper or a method to force the output of another program (let's say 7zip) inside a bash script to be formatted in a given way, say, coloured or indented? Or even run in a separate small ...
-1
votes
2answers
31 views

Loop over columns and store values to associative arrays

I've got a text file containing two columns, like so: 26 0.000342231 27 0.000342231 28 0.000684463 29 0.00136893 30 0.00102669 31 0.00308008 32 0.00308008 33 0.00444901 34 0.00718686 35 0.00718686 36 ...
0
votes
2answers
55 views

Transform row of integer into multi-column output

I am trying to get the input of a file to generate me a list with rows and columns of that numbers in sorted order. This will be use to generate a printable document later, so i am able to replace the ...
2
votes
1answer
44 views

What are the disadvantages of using config file (source) for passwords in bash scripts

I am writing a bash script that needs to authenticate a Linux box with active directory. I would like to make it so no user input is required. The problem is I have to put the password in the script, ...
1
vote
2answers
63 views

How tp Print/echo arrow key in unix - bash, version 3.2.52

How do I print ↑ and ↓ in Unix? Basically I have a script written in bash and I am printing some numbers with whom I want to print arrow keys to show increase/decrease. So how do I literally print ...
5
votes
4answers
599 views

How do I quickly move the cursor to the end in bash in vi mode?

When I'm in insert mode and I move left from the last cursor position (the empty spot to the right of the last character), then I can't go back to that position anymore. I have to type Esc$a (or ...
0
votes
2answers
103 views

What is the alternative for ls command in linux? [duplicate]

How can I list the current directory or any directory path contents without using ls command? Can we do it using echo command?
0
votes
0answers
29 views

Writing a basic shell script [duplicate]

I'm using a cluster and I want to write a start up script to run the commands I have to run at the beginning of every session. My script looks like this #!/bin/sh module add apps/COPASI module add ...
3
votes
1answer
41 views

What is the effect of the underscore in [A-Z] [_a-zA-Z0-9]*?

In regards to regular-expressions what is the effect of the underscore in [A-Z][_a-zA-Z0-9]*
0
votes
0answers
28 views

vim no tab completion in bash

When in shell, running vim <anything> and pressing tab, doesn't auto complete or show the list of the available files. Although it auto completes for the directory names, but not the file names. ...
2
votes
1answer
693 views

How would you get all users history

I know there is the $HISTFILE variable where i can find the currently logged in users history-file, but how can i be sure to get every history file on the server I was thinking of the ...
18
votes
4answers
16k views

Solving “mv: Argument list too long”?

I have a folder with more than a million files that needs sorting, but I cant really do anything because mv outputs this message all the time -bash: /bin/mv: Argument list too long I'm using this ...
0
votes
3answers
866 views

Split XML file into multiple files

I have an xml file that have different nodes, I want to split files like this: <unix> <mm> </unix> <osx> <nn> </osx> When I run the script I want it to make ...
1
vote
2answers
854 views

bash bad interpreter and permission denied

I installed RHEL 5.1 on a virtual machine. I would like to install VMware Tools, but I keep getting an error. I am performing the installation via the tar procedure. I get the following error: bash: ...
200
votes
14answers
59k views

Preserve bash history in multiple terminal windows

I consistently have more than one terminal open. Anywhere from two to ten, doing various bits and bobs. Now let's say I restart and open up another set of terminals. Some remember certain things, some ...
7
votes
2answers
4k views

cp -f cannot overwrite cp -i alias

In my /home/user/.bashrc file, I have those aliases to prevent mistakes: alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' If I'm really sure of what I'm doing, I can overwrite rm and mv aliases ...
0
votes
1answer
55 views

How to use pipe to assign a variable [duplicate]

I am new to bash script. Probably this is very easy but for me it's not working. How can I assign value of $x1+$x2 to bc by piping. here in my code $bc holds no value. echo -n 'value x1 : ' read x1 ...
-1
votes
1answer
90 views

Argument list too long with just 5000 files [duplicate]

I have a folder with 5000 files that I want to copy somewhere else. When I do cp ../folder* ., I get the following error: -bash: /bin/cp: Argument list too long However, getconf ARG_MAX returns ...
0
votes
1answer
25 views

How to make OpenVPN to autoreconnect to gateway at any time

I've recently discovered a built-in way to have OpenVPN to auto connect to VPN gateway on startup, which is via setting profiles .conf files in /etc/default/openvpn as a part of AUTOSTART parameter. ...
3
votes
2answers
55 views

read only TMOUT variable – workaround to disable automatically exit shell when there is no activity

We have here a read only Bash variable. I am not allowed to unset that variable. $ echo $TMOUT 1800 As a workaround I wrote those lines (that my session don't exit) #!/usr/bin/perl $|++; while ...
-5
votes
0answers
49 views

Where buitin variables are stored in bash?

Where can I find the code of bash builtin variables? I have downloaded the bash source code but cant find it inside. Are they themselves a script or code written in C-language?
0
votes
2answers
896 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 ...
1
vote
1answer
38 views

nemo: Context Menu Action Triggering a Script that Forces the Selected Symbolic Link to be Relative

My goal is to be able to right-click a symbolic link in nemo, triggering a custom script that forces the link to be re-written as a relative path, should it happen to possess an absolute path upon the ...
3
votes
2answers
34 views

Create folders for specific items in table

I have data organized in a table (text tab delimited) as bellow: NAME TIME ID DATE -------- John 03:25:01 A10A 2015/05/12 Marry 01:01:15 N000M ...
4
votes
2answers
445 views

how to edit and color bash's tab completion list

Following is what i would like to have. When the tab completion is ambiguous, and bash prints the list of possibilities. I would like it to colour the next character I should press inside every word ...
4
votes
1answer
55 views

Recursively grouping symlinks by original file

Pardon me, but I don't actually know where to begin with this - I will update if I get further. Sorry. Basically, I've got a list in a text file similar in structure to the following: ...
1
vote
2answers
39 views

A variable in Bash that contains quotation marks and spaces

I'm trying the following in a Bash script: MV_PARAMS='"foo 1" "foo 2"' mv $MV_PARAMS What I want to actually execute is: mv "foo 1" "foo 2" But it doesn't seem to work. trying this: mv ...
0
votes
2answers
57 views

Loop through * files using $1 in bash script

I am writing a script to act on files given to the script using the $1 variable. What is the best way to loop through these files. At the moment I have hard coded the script using something like for ...
-1
votes
1answer
53 views

Why is bash confusing this HEREDOC limit string as a command?

I am trying to use nested HEREDOC blocks in a bash script. Note The outer HEREDOC is user to run a list of commands as a different user via sudo the inner HEREDOC is capturing regular text to cat ...
0
votes
1answer
4 views

How to disable vcstime

There's a program /usr/sbin/vcstime which prints the date/time in the top/right corner of your terminals. You can enable it in /etc/kbd/config (on the last line). It's disabled by default. I'm having ...
0
votes
1answer
20 views

Bash exit from subcommand [duplicate]

I have a script with the following code: command_that_could_fail || (echo "command failed"; exit 1) However, the exit seems to just be exiting from the sub-command formed by the second part of the ...
3
votes
5answers
440 views

Bash - Sequence of numbers in the same line

I know the command seq to generate sequence of integers, one per line, but I would like to ask two questions: Is it possible to write the numbers of the sequence in the same line? Is it possible to ...
1
vote
0answers
20 views

How to quickly search and navigate to the particular sub directory? [duplicate]

I often find myself in the situation where the directory structure is like: a/b/c/d/f/g/... and I am at a as pwd and wish to quickly navigate to f or g. Is it possible to search and move to the ...
3
votes
3answers
87 views

Organize entries as a spreadsheet (csv) using awk

I have information for entries (N= 1000) saved on a computer in a delimited text file/per entry ( every entry has one text file). The information recorded in the same format as the following: ...
1
vote
1answer
51 views

Bash script with “execute” command and strange regexp

So I was looking through Paul Irish's dotfiles and found reference to this bash script: #!/bin/bash cd "$(dirname "$BASH_SOURCE")" \ && source 'utils.sh' declare -a FILES_TO_SYMLINK=( ...
4
votes
1answer
60 views

How could a script know the path of the .desktop file that launched it?

How would a bash script know if it has been launched by a .desktop file, and how would it know the path of that launcher? Extra Points: How would I extract the "comment" field of that .desktop file - ...
3
votes
1answer
43 views

Bash test on successful subshell command returns false

I don't quite understand this behaviour of bash test operator. I used this line to determine if vagrant is installed. if [ $(vagrant --version > /dev/null) ]; then echo "HELLO"; fi I now know ...
3
votes
2answers
860 views

dialog, trap and SIGTRAP

I've seen a lot of examples using dialog tools into scripts with lines as follows: trap "rm $datafile" 0 1 2 5 15 What I don't understand is the meaning of SIGNAL 5, ok I know is SIGTRAP. But shame ...
1
vote
1answer
60 views

grep entries from delimited text file and include it in another command

I have database for persons and path to their files which stored on a computer. This data saved as (a very long) delimited text file as follows: ============ NAME: John TIME: 12:31:25 PATH: ./a/b/v/c ...
0
votes
2answers
57 views

Bash script arguments not being passed to function? [closed]

I'm trying to pass the arguments when invoking a bash script to a function defined in that script. In my head this is trivial but in practice seems more difficult. Script is: #!/bin/bash function ...
1
vote
1answer
672 views

LFTP mirror includes - including other directories other than what I've included

My question: How can I make sure LFTP only includes files AND directories using --include or --include-glob, and not download a bunch of extra directories from the root of the remote that aren't in ...
4
votes
5answers
189 views

Remove characters while naming files or folders

I have a text file with multiple rows. In every row I have the date in the following format: 12/2/2015 15/9/2013 08/3/2011 02/5/2005 . . . I want to create a folder for every line in this text file ...
1
vote
1answer
79 views

Bash script (with a java command) does not exit (script 2)

I start a bash script (synchronously from java as glassfish user) which triggers another bash script: Script 1 executed from java: #!/bin/bash #Start script2 as myUser on myUser desktop echo ...
0
votes
1answer
16 views

Bind C-j to backward-kill-word, says command not found

bind -x '"\C-j": backward-kill-word' says, backward-kill-word: command not found As mikeserv quoted here, i am able to do backward-kill-word using Ctrl-w. However this is the same key i use in ...