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
9 views

Capture in shell variables the arguments after a command (between brackets)

Suppose I have a file that contains, among many other things, \command{arg1,arg2,arg3} (arguments been paths, expressed with /, ., characters and numbers) But that a user can as well call it ...
0
votes
2answers
17 views

add a new line to a delimited file

So I have a file name test.txt inside that file I have about 20 lines of text that are delimited by pipe | Example: John|freshman|seatle|math|4|fulltime Bob|senior|Tacoma|biology|4|part-time I ...
-1
votes
2answers
27 views

ps output / pipeline execution order

I run ps aux | grep somethinghere. The output shows the grep somethinghere as a running process. My question is, shouldn't ps aux finish first, then grep somethinghere run on its output? Maybe there ...
0
votes
1answer
8 views

Resizing Whiptail to full terminal screen

How to make whiptail full terminal screen? "as big as the terminal", like fluid CSS, something like 100%
1
vote
0answers
17 views

Questions about whiptail and bash functions

I'm a bash newbie. Say I have this script #!/bin/bash function cpp-lang { yum install "Development Tools" } function updatesys { yum -y update yum -y upgrade } whiptail ...
0
votes
0answers
9 views

What port uses my backportpackage or bzr?

I am working in a company what uses Ubuntu Precise on the desktops behind a proxy. The Proxy is available in /etc/environment and set as: http_proxy, https_proxy, ftp_proxy, no proxy and their ...
0
votes
1answer
37 views

Bash escaping is confusing me

Lets say that I have a file (executable) called literally 'a\b'. It just echoes some stuff. Now I want to call that and I can do it by inputting user@machine:~/test$ ./a\\b into my console. Now ...
0
votes
1answer
15 views

Redirect all bash script output (from inside the script) to two files: one append, one rewrite; but discard output to the console

I can easily redirect both standard and error output of a bash script to the file, while discarding an output to console with simple exec statement: exec &>>/var/log/backup.log But how do ...
1
vote
1answer
30 views

Whats wrong in creating/printing this array?

To find the average time taken to create certain files, I'm using this minutes array, then would simply use bash arithmetic to find the average. However I'm unable to get the difference except for the ...
0
votes
1answer
21 views

vim - “Press ENTER or type command to continue” right after loading only?

Recently my vim has developed the habit of displaying Press ENTER or type command to continue the first time I do certain things right after I open it. For example, if I'm at my shell prompt and type ...
0
votes
2answers
26 views

process substitution for opening a list of files with an application

I wish to use process substitution to direct a list of files (produced, for example, by ls or find) to a particular application for opening/viewing. While piping such a list to xargs is suitable for a ...
3
votes
1answer
64 views

Unix: Bash Limiting Output to X Amount of Lines

I am trying to modify a script so that it will truncate the output that goes to another file to a maximum (for example: 1000 lines). I have read about split, but what I understand is that split by ...
0
votes
1answer
15 views

Setting up a script on an AMI box to create directories - vsftpd, pam, mysql

I'd like to first say I'm a noob when it comes to linux, so please excuse my confusion. I'm trying to setup vsftpd on a amazon ami 64 bit box, free tier micro. Following these instructions, ...
2
votes
2answers
242 views

How do I use a function return as a condition of an if else then shortcut?

There are instances where a function needs to execute and return to the caller and this works for me. if tst; then echo "success" else echo "failure" fi function tst () { return 0; } ...
1
vote
0answers
10 views

java version not found in redhat

My OS is redhat linux. It's having the default java 1.4.2, but I need java 1.7.45, for that I am trying as follows: /usr/sbin/alternatives --install /usr/bin/java java /u01/java7/bin/java 5 ...
2
votes
3answers
130 views

Loop over associative arrays by substring

In the following code, I create some associative arrays in a loop. The consist of two strings, a string identifier and a year. After creation, I want to access the arrays in a loop based on the ...
0
votes
2answers
32 views

Locate specific file from script

I've written a script file in which, one function searches for another script and if found, executes that script. Script extract #!/bin/bash ... service_status() { local my_script=`which ...
2
votes
1answer
18 views

Strange characters in GIT completion

I'm running bash GNU bash, version 4.3.25(1)-release (x86_64-apple-darwin13.4.0) on OS X 10.10.1. A week or so ago I've noticed that autocompletion has stopped working, but only for git. I'm ...
1
vote
1answer
25 views

Broken git autocompletion after I have overridden the git command

Recently git branch <tab> started showing me the following error: $ git branch bash: -c: line 0: syntax error near unexpected token `(' bash: -c: line 0: `/usr/bin/git --git-dir=.git ...
0
votes
1answer
24 views

Error while running script with nohup

I got this error while running my script with nohup sh: syntax error near unexpected token `(' My script is as follow: #!/bin/bash report_log="report.log"; grep -A 3 'successful\|ERROR COUNT ...
1
vote
2answers
40 views

script that lists all files in a directory and subdirectories sorted by size, listing only file names not complete paths

I'm looking for a script that lists all files in a directory and subdirectories sorted by size, listing only file names not complete paths. find . -type f -exec ls -lhS {} \+ works but gives the ...
5
votes
1answer
29 views

Using process substitution to trick programs expecting files, with specific extensions as argument?

Here is my use case: the command line utility melt can accept a file name, with the extension .melt on the command line, and open it; as an example, this is a proper test_p.melt file: colour:blue ...
2
votes
2answers
32 views

how to workaround a deadlock (multithreading a program)

I need to run a program 100 times, a few hours each, which is fine when running it in a serial way, just takes very long, but when I try to parallelize it using GNU parallel or simple '&' in bash, ...
-5
votes
2answers
34 views

placing things in a users home directory with .deb

i am making a .deb installer and would like to place some files in the users home directory but i can not hard code a username. does any one know of any other places in the file system that i could ...
0
votes
1answer
35 views

finding and replacing text [duplicate]

Does any one know how to find and replace text in a file. it can be implimented into a bash file. i would like to find the line and the output the text to it the file can only be opened with the root ...
0
votes
0answers
17 views

bash/svn how to filter documents [on hold]

Does anyone know how to filter documents. For example, if I had something like this: dVa/Prs/Upe/dVar.var I want to only the last file in log and then add to this file another for example after ...
0
votes
1answer
17 views

Unix: Looking to run a script in directories with a certain name

I am writing a script in bash. If I am in directory Foo, I want to run this script in only the subdirectories of foo that are named foo with up to three numbers after foo. Ex: foo1, foo23, foo345 ...
2
votes
1answer
60 views

Bash: command substitution with multiple unset/export commands

I am trying to unset some variables and export others using command substitution. This works: $(echo " export TEST_A=1 export TEST_B=2 ") And this too: $(echo " unset TEST_A ...
3
votes
3answers
70 views

The output I get via “echo” works as a command when pasted to terminal, but not in the script

I'm trying to change the files generated by an app that unfortunately often contain spaces. I have managed to get "echo" to give me output that works if copy pasted into terminal, but when I try to do ...
0
votes
2answers
27 views

Command substitution and spaces

Why does this work as a calculator: [root@qabun02 ~]# echo $(( 5+2 )) 7 but this doesn't? [root@qabun02 ~]# echo $( (5+2) ) -bash: 5+2: command not found The only difference I can see is the ...
0
votes
1answer
18 views

Bash script: array elements containing space character [duplicate]

I'm getting started with bash scripting. I'm working with array elements that contain space characters. In the code below, the third array element is "Accessory Engine". I tried to set the space ...
1
vote
1answer
74 views

Why does the printf statement in this loop output the array out of sequence?

When I execute the following code, the output of the printf statement appears to show array out of sequence. In the declare statement the Source item is declared before Destination and in the output ...
3
votes
1answer
48 views

Can I run a command loaded from .bashrc with sudo?

I have some custom functions and aliases defined in my .bashrc file. Sometimes I need to execute whem as root. I then do something like: $ sudo custom_cmd 80 ...
0
votes
2answers
59 views

How to convert Log file to CSV using bash

Is it possible to turn this log entry into a properly formatted csv file using sed/awk? I've tried multiple ways to do this using sed/awk. Alas I couldn't do it. Before I do it in perl. is this ...
2
votes
3answers
59 views

How to get tab completion when using curly braces in Bash

I want to have tab completion when using curly braces in a command in bash. For example: cp ~/html/{foo bar.txt whatever} /var/www/html/ I want the tab completion for the files stated in the curly ...
2
votes
3answers
72 views

Using find with 2 sets of variables

I want to be able to run a find command in my bash script that will find files based on two seperate variables. I've gotten this far but I'm not sure how to get the final result workingfind . -user ...
0
votes
2answers
53 views

Untar and gzip from multiple sub directories

I have a directory which consists of multiple sub-directories. Each subdirectory has a tar.gz file which on untar gives two files namely R1.fastq and R2.fastq. I want to untar the tar file and ...
0
votes
1answer
30 views

Opening a socket in Kali Linux using bash scripts

I know how to open a TCP or UDP socket in Ubuntu, with the following command : exec 3<>/dev/tcp/google.com/80 for example: we can open a TCP socket on port 80, but in Kali Linux there's no ...
1
vote
1answer
42 views

Read a character from an x-y coordinate on the screen

Is there a way in bash to read a character from an x-y coordinate on the screen? This command would be something similar to cget 12 30 which would return the character at the 12th row and 30th ...
0
votes
2answers
24 views

redirect output from interface?

I am echoing an AT command to a modem interface (/dev/ttyUSB3) and the command runs successfully. For instance the below command works and has an output of OK: echo -e "ATZ\r" > /dev/ttyUSB3 I ...
0
votes
2answers
22 views

The best way to add Unix Shell variables to CURL GET request

Let’s say I use curl –X GET command with the following link: “$WEBSITE_URL/ACTION_NAME/ACTION1;id=$ID?Command=TEST&id1=$ID1&id2=$ID2&id3=$ID3” As you can see, there are some $variables ...
0
votes
1answer
28 views

I don't see .bashrc file in my /home and /etc/skel direcories

I am running linux mint 17.1 rebecca, but I have found it quite different with other distros I am used to, in /home and /etc/skel there's no .bashrc I don't know if i mess up with something or it is ...
0
votes
1answer
18 views

Tar Create and Split files into subdir

I have this command: tar -cf - input/* | split --bytes=1m Which splits my huge gz files into small ones. This works fine. However I want the output (the small files) to be created in the input/ ...
0
votes
1answer
13 views

Universal .bashrc alias showing results of sysytemctl start command

This is small .bashrc alias that allows me to see results of starting service alias systemctl start apache='systemctl start apache && echo SUCCESS || echo failure' How can i modify to work ...
1
vote
2answers
35 views

Do programs source .bashrc when run?

I append to my PATH environment variable in my .bashrc file (Ubuntu v12). I also have a service (Atlassian Bamboo) that relies on the modifications to PATH. When I restart the service (which runs as ...
2
votes
2answers
57 views

Using the output of `grep` as variable in second command

I currently have 2 bash command line strings I use to gather data needed for a certain task. I was trying to simplify and have only one command used to gather the data without using a script. First I ...
2
votes
1answer
16 views

Is there an alternative to using rbash to restrict a user on my system?

Basically at the moment I am using rbash to stop a user from leaving his directory on my system. The problem with this is, there is a script in my bin which he needs to be able to run from a script in ...
1
vote
2answers
50 views

ls .. doesn't work properly with symlinks

I have directories set up a bit like this ~/code ~/code/src ~/code/build -> /path/to/somewhere/else That last one's a symlink. If I do this cd ~/code/build ls .. then I get the listing for ...
1
vote
3answers
207 views

How to copy files from the folder without the folder itself

I'm trying to copy files and subfolders from A folder without the A itself. For instance, A folder contains next: | file1.txt | file2.txt | subfolder1 Executing next command gives me ...
8
votes
2answers
418 views

Run another command before running the command the user wants to run

Let's say I want to modify the original behavior of the ls tool this way: $ ls Hello World file1 file2 ... How can I do this? When running ls I would like to run another command let's say echo ...