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

-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
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. ...
0
votes
1answer
29 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
56 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?
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, ...
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
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: ...
0
votes
2answers
58 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
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 ...
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
88 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
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 ...
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 - ...
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 ...
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 ...
4
votes
5answers
190 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 ...
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 ...
0
votes
3answers
46 views

Splitting a pdf-file into 2 pdf's (one contining equal pages etc…) [duplicate]

I have a 600 pages long pdf file. I would love to be able to split it in different pdf files, one containing odd-numbered pages: 1,3,5,7,9,11 etc. and another file containing even-numbered pages: 2, ...
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 ...
2
votes
0answers
30 views

Restrict a user from viewing other user's processes [duplicate]

Suppose there are two users : user1 & user2. Now we know that if I give top -u user1, I can see only the process respective to user1. But if I do top -u user2, I can see all the process running ...
0
votes
2answers
27 views

Simple bash not running properly by cron

I created a small bash script that takes a file using wget and then processes it using a php. The code goes like this: wget -U mozilla -P /home/logfetcher/ http://fakesite.com/log.`date -d ...
1
vote
2answers
44 views

Store array to file and load array from file in BASH [closed]

I want to be able to store multiple integer arrays into a txt file when I'm done updating them, and then be able to load these arrays from the txt file into the script that I am using. The arrays ...
2
votes
4answers
167 views

How do I *reliably* and *simply* get the current shell interpreter name?

I'm looking for a simple and reliable way to get the name of the current shell from inside a script or a sourced file (not from the command line). I would have expected to just do $(basename ...
0
votes
2answers
58 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
2answers
62 views

Can bash shells automatically recognize Gnome terminal window's width?

/bin/less is the default pager on an Ubuntu 14.04.3 LTS desktop OS (the $PAGER variable is unset) and gnome-terminal 3.6.2-ubuntu1 is used. If I try for instance: $ man man The displayed output ...
1
vote
1answer
40 views

How can I hide the output of command line in terminal window?

Bellow is a simple code: #!/bin/bash -ef echo "Hello" > log.txt #saving the output of this command log.txt command1 #this command running and showing it is output in terminal command2 > log.txt ...
4
votes
2answers
93 views

How to tail a log file by time?

Say my log file(log.txt) is something like 2014-01-01 22:30:30 something happened.... 2014-01-01 22:30:31 something happened.... 2014-01-01 22:30:41 something happened.... I want to tail this file ...
0
votes
0answers
20 views

Multiple here documents in a bash script to drop in and out of sudo is causing error “Sessions still open, not unmounting”

I'm attempting to write a setup script that I can run on multiple machines to run a bunch of installers (requires sudo) but also do things like pull down a git repo (I want to run that as the normal ...
2
votes
4answers
150 views

How to take the absolute value using awk?

If I have below two dates: 2015-09-12,2015-08-13 And I need to get the number of days between them, I will use the below code: awk -F'[-,]' '{print 360*($4-$1)+30*($5-$2)+($6-$3)}' The output ...
7
votes
1answer
589 views

Bash: How many nested sessions deep?

Say I start a bash shell, ...and then another bash session from within that shell, ...and then another bash session from within that session, ...and then another bash session from within that session, ...
0
votes
1answer
49 views

Executing command in a script as other user takes 10-15 seconds before execution

I start a bash script (synchronously from java as glassfish user) wich start a command as an other user (let's say myUser): #!/bin/bash echo myPassword | su -c "command" myUser & When I start ...
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 ...
1
vote
1answer
35 views

Bind Ctrl-\ in inputrc?

I've been futzing around with this and can't seem to get it to work. Using Ctrl+V in the terminal correctly outputs ^\ for this combination so it should be recognizable. As I have Ctrl+\ bound to ...
0
votes
0answers
20 views

ln -srf is alternating between two different linking behaviors

I'm currently working on putting my dotfiles under version control, and I'm running into a weird behavior with ln -srf. My setup consists of a directory /home/agentwiggles/Code/dotfiles, which ...
1
vote
2answers
48 views

copy recursively skipping directories with specific name

I have a directory with ~100 Gb. I need to copy this directory to other place skipping specific folders (there is a lot of them). The following is a wrong code to demonstrate my needs. $ cp -r ...
2
votes
2answers
62 views

is a script, program being run under current shell or child shell?

I am confused with regards to the following - if i execute a script or run a program in the current shell by typing on its name 1st) it search in the $PATH variable, to find the location of the ...
1
vote
1answer
23 views

Here Document on Platform LSF

I am trying to perform process substitution within a command passed to Platform LSF via bsub. On the worker node that I submit my job to, process substitution is not enabled because it is not a POSIX ...
1
vote
1answer
30 views

Get the filename that the record come from

I have a huge number of .gz files, which being uncompressed using zcat together. I am looking to get from where each record came from, as below example: File1: 1,2,3,4,5,6,7,NEW,9,10,11,12 ...
2
votes
1answer
105 views

how to split multiline records by awk?

How to split multi line records by awk, i.e below file: ...
0
votes
1answer
19 views

Have to transform some bunch of csv in req format and store it in some other location with same name

I am having some input CSV files INPUT_FILE: A_B_C_NFM001_20150729.csv A_B_C_NFM002_20150729.csv A_B_C_NFM003_20150730.csv I want output file also with the same name as input after performing below ...
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
0answers
84 views

Bspwm and Lemonbar - integrate bash script into the current bar

So I've got lemonbar (formerly bar) with Bspwm up and running. I have the colors the way I want them. I also have a bash script, which when run separately from Bspwm - just "./bash_script | bar -p" ...
0
votes
0answers
33 views

Ctrl + y on shell terminal, paste from system clipboard [duplicate]

I use emacs style bindings for my bash terminal. And i use only the system clipboard and never use any of the application specific/primary selection stuff. When i copy text from emacs window and use ...
0
votes
2answers
39 views

Rename specific level of sub folders

I have list of sub folders inside a parent folder as follow: Parent folder folder1 foldera folder2 folderb folder3 folderc I want to rename the subfolders only in ...
2
votes
1answer
41 views

Running compilation scripts only if the source file is more recent than the compiled programe

all. I'm not sure if this question belongs here or some other site but I figured I would start here and some helpful moderator would kick me over if there is a better location. What I am trying to ...
1
vote
1answer
45 views

How do I get a folder name using a wildcard and check for it's uniqueness

I want to move a series of file into different folder based on their ID, but I want to make sure that the folder I'm moving the file to exists and is unique The folders have a matching ID as the ...
0
votes
1answer
62 views

mv: cannot access file

Good day All, I have a script with permissions - 770 root:root script.sh. The scripts has to zip then moves files with permissions - 644 rex:roger file.csv. With a bash one line - mv file.csv ...