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
2answers
60 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
41 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
95 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
167 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
591 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
50 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
84 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
38 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
50 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
31 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
106 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
93 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
40 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
67 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 ...
1
vote
1answer
35 views

How can I remove part of folder name

I have list of folder names file1xxx file2xxx file3xxx I want to remove "xxx" from it's name. I tried the following bash for dirname in $(cat ${in}/all.txt); do # all.txt include the name of the ...
2
votes
3answers
180 views

!(*.sh) works on the command line but not in a script

When I use the code below in a terminal on Ubuntu, it works fine: rm !(*.sh) -rf But if I place the same line code in a shell script (clean.sh) and run shell script from terminal, it throws error ...
0
votes
2answers
35 views

wget, logging the output and the response

I calling an url using wget. This url gives me a response, its a Message id. I want to write the logs to a log file, with the message id as well. Also the log should be appended each time. I trying to ...
0
votes
1answer
24 views

Faster way to enter in command mode with vi mode in the shell

I want to use the vi mode in bash but I find the ESC key a little bit too far, as for vim. The ideal can be to keep a key pressed, like ALT or the caps lock, to stay in command mode and be in insert ...
2
votes
5answers
561 views

How to add a password to a BASH script

I want to create a script to run the following BASH command: mysqldump -u [username] -p [db_name] > [path to backup file] Which results in a backup file. When running this in BASH, it prompts ...
0
votes
4answers
128 views

Fast way to add/append to large a file [closed]

I have a bash script that reads a rather large file, line by line, and for each line does some processing and writes the results to another file. Currently I am using echo to append to the end of the ...
0
votes
3answers
46 views

How do I create a directory for every file in a parent directory

I have parent folder and inside this folder I have 4 files ParentFolder File1.txt File2.txt File3.txt File4.txt I wanted to create subfolders inside the parent folder and ...
1
vote
2answers
71 views

Difference between dates by awk

I have the below file: 1,2,3,4,5,2015-10-13,7,8,2037-01-15 1,2,3,4,5,2015-09-05,7,8,2040-01-15 1,2,3,4,5,2015-09-15,7,8,2016-06-15 1,2,3,4,5,2015-10-13,7,8,2015-07-08 ...
0
votes
1answer
29 views

How to concatenate tables from different directories with only one header [closed]

I have several directories ("amazon", "niger",...), in which I have several subdirectories ("gfdl", "hadgem",...), in which I also have several sub-directories ("rcp8p5", "rcp4p5",...). In this last ...
0
votes
1answer
58 views

Redirect console output in sed in background process don't give back hand

I'm using sed to add the date at the beginning of every lines given by a command (which use vlc and never stops...). I found this way on another stackexchange post and that works as expected. command ...
0
votes
1answer
30 views

Problem with loading settings from .bashrc

I have got strange problem with terminal settings. I am Debian 3.16.7 user. I saw .bashrc file using ls -a but I couldn't open it (no file comunicate), so I restored it from /etc/skel/.bashrc. Now ...
1
vote
2answers
44 views

How to forcibly update a file if left unchanged after 55 minutes? [closed]

I need a log file to be updated if it has been left unchanged during 55 minutes. For example, say it is now 19:00 and IOstatDisk2.log hasn't changed since 18:00: solaris1a:/var/tmp ROOT # ls -ltr ...
14
votes
2answers
337 views

Resource usage using pipe and here string

We can get the same result using the following two in bash, echo 'foo' | cat and cat <<< 'foo' My question is what are the difference between these two as far as the resources used are ...
0
votes
2answers
61 views

How to use cp command in bash script to copy files with spaces ans $ characters in it? [duplicate]

I am trying to copy some files with spaces and $, @ symbols in their file names in a bash script but the script fails to copy the files stating it cannot find the file. I can see that it is treating ...
0
votes
1answer
26 views

Folder organization

I have several folders ("amazon", "niger", "rhine",...). Inside each of them I have several subfolders ("gfdl", "hadgem", "ipsl",...). Each subfolders is composed by 5 subfolders (e.g. in "amazon", ...
-2
votes
1answer
58 views

Bash Code Injection Vulnerability On Linux

Found a new bug in Linux System, a bash code injection vulnerability. The solution to this is the update the bash package. yum update bash My Question is "do I need to reboot the system"? ...
3
votes
2answers
133 views

Using bash variables in perl command in bash script

I am trying to generate a hashed password as in /etc/shadow file, using bash script. The user is prompted for the password which is saved in a variable PSWD. I have extracted the Hash and the salt ...
1
vote
0answers
53 views

Recording shell output for interactive commands

While looking into a shell redirection problem, I found a couple of answers that pointed me to the script command. As I understand it, script just records in- and output of the terminal, and allows me ...
1
vote
4answers
94 views

Set, backup and restore colors in the terminal

I use this program to display all color available in the terminal. That waht I get: This program doesn't show me colors below 100. Why? Is there a way to display them. Is the are way to change ...
1
vote
1answer
46 views

error ./c.sh: line 24: [: too many arguments in shell program

I am trying to make a shell script to print the amount of time user was logged into the system but I encountered a too many arguments error. I tried many methods from the internet but none worked. ...
2
votes
1answer
88 views

Issue with ':' character in Bash script over SSH

I am currently writing a script that will perform backups on a set of databases, comress them, encrypt them, transfer them to a separate storage machine, and verify that the file made it successfully. ...
1
vote
2answers
60 views

What Bash Statement does

Can you explain to me what the below statement does. grep `date +%Y-%m-%d --date='1 day ago'` /path/to/file/FILE_PREFIX_\`date +%Y%m%d --date='1 day ago'`.dsv | grep -v 'ERROR' | cut -d "|" -f 2 | ...
3
votes
3answers
161 views

If statement string comparison

I'm reading a csv file with 14 values per line. I want to convert the HEX value from 10th [f10] value to a DEC value. In order to do this if the 7th [f7] value must hold EnHr or EnSt or SpJb or Chem ...
1
vote
4answers
58 views

One column into two

I have a file that is one column, and I need to split it into two. Have tried column command and doesn't seem to work: 123-zyx 234-yxw 345-xwv 456-wvu 567-vut 678-uts
3
votes
2answers
74 views

Why does man page completion fail after su?

I have a default Debian 8.1 installation. I do su man apt<TAB> but get nothing. I do see the manual when I write man apt-get in both modes: as user mas and as root. However, tab ...
1
vote
1answer
67 views

Reload network interfaces without rebooting

I'm doing a BASH script for Arch Linux in a Raspberry Pi 2. The thing is that in some point I'd like to reload the network interfaces without reboot and have my new named network interfaces (en0 and ...