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

prevent a command from sending both stdout & stderr to any terminal or file

I would like to prevent my program from sending stdout and stderr to any terminals, files or devices. For this, I have three command crossing my mind, but I cannot distinguish their differences. Could ...
0
votes
0answers
23 views

How do I write a script for testing username/password?

I have about 500+ hosts I need to test a username/password combo to make sure there aren't any false positives in the list. I just need to make sure I can login and log out, no need to run anything ...
0
votes
3answers
64 views

script using sed command

I need your help using sed command I have this output as a result of difference between two file: < IF-Name :STRING: "lns-wall-01-t2" Index:Gge32: 260 --- > IF-Name :STRING: ...
0
votes
6answers
30 views

How can I filter out a specific part of a JSON response in bash

I'm using wget with -qO to a specific updater URL for OpenELEC which provides the following JSON response, similar to the one below. ...
7
votes
1answer
171 views

Bash wildcard to match exactly n characters

Is there a wildcard in bash to match exactly 5 characters, shortening a pattern like ?????
0
votes
1answer
19 views

Dialog radiolist using dynamicaly defined array of choices

Following my previous question, I have write the following MWE to create a simple file selector by date filesArr=( $(ls -1rt ??????????_?) ) nfiles=${#filesArr[@]} iLastFile=$[nfiles-1] choiceArr=( ) ...
1
vote
2answers
37 views

Bash / Linux Tools for correcting xml

I am generating a set of 'xml' files from a 'csv' file. Some of the fields in csv file contain '&' and other invalid xml characters that need to be replaced with their appropriate xml counterpart ...
4
votes
1answer
149 views

bashrc lazy substitution

How does one get ~/.bashrc aliases to evaluate $() substitutions at run time, instead of at the time that ~/.bashrc is executed (when opening a terminal)? I run this command often enough that I would ...
2
votes
2answers
135 views

Extract group name from `id` and store it in a variable

$ id usera uid=830(usera) gid=799(groupa) groups=799(groupa) I need to extract the group name from the output of id and store it in a variable. In this case it's groupname=groupa
0
votes
0answers
17 views

mdoc warning: Empty input line #xx

while searching man pages using grep ( man tar | grep compress) I am getting this error: mdoc warning: Empty input line #xxx xxx can any number Is grep giving this error or something else? how can ...
1
vote
3answers
97 views

tar unix not changing directory

I am executing a tar command to compress files which are present in another directory. I executed following command: tar -czf /backupmnt/abc.tar.gz -C /backupmnt/statusService/ * I want to create ...
1
vote
1answer
72 views

Command to wipe every file added to the system

Is there a command that I can use in order to wipe every file that I, personally, have added to the system? I don't want it to delete any essential system files – I'm still going to be using the ...
3
votes
1answer
31 views

using shortcuts to move in bash command line [duplicate]

When I use Ctrl+Left_arrow or Ctrl+Right_arrow in bash, I move backward a "word" and forward a "word" respectively. I belive, this is defined in /etc/inputrc # mappings for Ctrl-left-arrow and ...
1
vote
0answers
22 views

How to get stdout of process? [duplicate]

I started a process from the command line, but the window server died. However I see the process I started is still running. Is it possible to connect a terminal to the process to see its output? ...
5
votes
3answers
268 views

How can I make a script take multiple arguments?

This is a very simple script #!/usr/local/bin/bash set -e if [ "$#" -lt 1 ] then echo "Please insert at least one argument" exit else echo -e "\c" fi if [ -h "$1" ] then echo "$1 is a ...
3
votes
2answers
290 views

How to print out only the script name?

[username@notebook ~]$ cat foo.sh #!/bin/bash echo "$0" [username@notebook ~]$ ./foo.sh ./foo.sh [username@notebook ~]$ Question: How can I output the "foo.sh"? No matter how was it executed.
-3
votes
0answers
20 views

Duplicate Image Searcher using Bash [on hold]

I need to create a script to search through a directory (and sub-directories) of a user’s choice, creating a SHA1 hash value for each image. Each calculated value will need to be compared, where the ...
4
votes
2answers
316 views

What defines “ll” in Fedora?

In Fedora, instead of typing ls -l, you can type ll. What causes this behavior? I've installed a new Debian system that does not appear to have this functionality. They're both running Bash. I can ...
0
votes
2answers
27 views

Add some text while output to file

Assume I have this command: ./clang-$j.out >> clang-result.txt and the each output for clang-$j.out is a fixed-length hash value (each program per line), however, I want to distinguish them by ...
0
votes
0answers
26 views

compare dynamic file [on hold]

I have a list of file that will be updated each hour and the name given to these file is according to the date and the hour for example: list_hour_date.txt list_9_20042015.txt list_10_20042015.txt ...
1
vote
1answer
27 views

How to run a shell script (bash) on a chromebook?

I have a shell script and I need to run it in order to connect to a remote ubuntu linux machine having encrypted HDD, in order to enter the passphrase. There's a shell script for this, but I have a ...
8
votes
2answers
378 views

Jump out of a process when it get stuck

I have written a loop to iterate all .out c binary file and copy their outputs into a text file (the output for every binary file is just a one line hash value, one line output for one program). Here ...
-6
votes
0answers
41 views

Adding a character to the end of a word [on hold]

I have a text file and I want to add a character attached to each word of the file.
1
vote
3answers
32 views

update-rc.d doesn't accept the header of a script file

I have beagleBoard and I want to start my script at boot time ( boot/reboot). So, i ran command: update-rc.d GatewayStart.sh defaults Output which says: header is rejected ...
2
votes
2answers
57 views

Where does the TERM environment variable default get set?

When I open a terminal window with the GNOME Terminal emulator in the desktop GUI the shell TERM environment variable defaults to the value xterm. If I use CTL+ALT+F1 to switch to a console TTY ...
0
votes
2answers
20 views

How to print arguments from a known element until an unknown element of an array with Bash

I am having a blonde moment. This is my data from myfile.csv 1429829254,e,SE,StckXchg,HDCU3000623,d,scan,253,47968,94,1420824420,JSSE-213,199,BS,KIT,*OUT* ...
4
votes
3answers
198 views

Is there a way of reading the last element of an array with bash?

If I have an array with 5 elements, for example: [a][b][c][d][e] Using echo ${myarray[4]} I can see what it holds. But what if I didn't know the number of elements in a given array? Is there a way ...
0
votes
0answers
24 views

tmux status bar path customization with sed

On the server I connnect to my home path is like this:/home/junk1/junk2/user. I can use the sed command pwd | sed -e 's|^/\([[:alnum:]]*\)/[[:alpha:]]*/[[:alpha:]]*|/\1|' to shorten the directory path ...
1
vote
2answers
44 views

Change color of input text, not output [duplicate]

I need to capture screenshots of the terminal where the typed commands visually "stand out" from the rest. Right now I'm using this to make my typed commands "red": PS1='\[\e[0;31m\]\u\[\e[m\] ...
-1
votes
0answers
38 views

Bash forward all the arguments (including quotes) [on hold]

In my bash script I need to call a java program with the exact argument as their inited n the script. For example ./test.sh -a "myfile.txt" -d "my regular expression" mydirectory The main problem ...
3
votes
2answers
257 views

Why I should avoid loops in shells? [duplicate]

The following link recommends against using loops in shells. bash variables in for loop range Why is this? Here is an example loop I just happened to be looking at when I came across that answer: ...
1
vote
0answers
16 views

Is there a way to make bash recognize aliases with prefixes [duplicate]

Assume you defined the alias alias grep='grep --color=auto' in ~/.bashrc. Then invoking sudo grep wouldn't trigger the alias to be used. Is there a way to do so? If yes, would that solution be ...
0
votes
1answer
29 views

Find all paths added to PATH [on hold]

I'm trying to uninstall some things from my system. I know that I can call them via the Terminal on Mac (bash) but I don't know where to find the files to remove them. I figured if there was some way ...
1
vote
2answers
47 views

shell script to get collect pixel size of image

I'm trying to create shell script that returns the largest picture in total dimensions pixel size? For example: I have many directory over 7000+, each directory have images: dir_1/ picture_1.png = ...
2
votes
2answers
179 views

Why do I receive a “/bin/bash cannot find command” error for an alias?

I am using multiple python, I alias python3 to py: alias py="/opt/python3.4/bin/python3" I want to run python in vim so I write this: map <F9> :call SpecialCompileRun()<CR> func! ...
0
votes
1answer
26 views

Multiple input files and output files in awk

I have a folder full of text files named 000.txt to 181.txt. How can I process all of them with the same awk script (program.awk) and send them to their respective output files (output000.txt - ...
0
votes
1answer
23 views

Persistence Bash history between detached processes

I haven't yet been able to find this among the bash documentation so I was hoping it could get answered if I asked it here. Is there any way that I can, on execution of a script, branch its history ...
5
votes
3answers
219 views

Is it possible to echo into a file, but use indenting in the shell script source? [duplicate]

If I have some nested and indented statements that echo a multi-line string into a file, the indents from the original shell (in my case bash) will be carried over into the target file. To avoid ...
1
vote
1answer
43 views

Extracting duplicity backup data

I've made some backups of my previous systems using Deja Dup (duplicity). In my current distribution it's not available, so I've simply extracted the data. Now in order to make that data meaningful ...
3
votes
2answers
37 views

Remove data from the STDIN stream buffer of another TTY session

I encountered a problem the other day while running multiple tty sessions in separate terminal windows. I was running a expensive disk access command and was waiting for it to return. Meanwhile I was ...
1
vote
3answers
53 views

Last exit status from within script without source

Supposing someone invokes a non-existent command, the only way I know to retrieve its error status from a script I execute right after is by using source I.e., let's say this script's name is dummy ...
0
votes
0answers
42 views

Shell intervals using awk

I have a file a 10:10 10:30 b 12:15 13:15 c 16:54 17:54 and I need to enter interval for example 10:15 so my output should be a 10:10 10:30 How I need to do that using awk?
0
votes
1answer
25 views

Run script from GUI with terminal output

I would like to run a script from the GUI. For example a simple echo "hello" from the right click context menu. In my case I would set up an action in thunar like this: Then it appears in the ...
1
vote
2answers
33 views

Using sed to replace javascript code in multiple files

I need to replace an old google analytics code with the new universal tracking code in lots of static html files. The old code looks like this: _uacct = "UA-XXXXXX-X"; urchinTracker(); The new code ...
-1
votes
0answers
30 views

Shell script for electrum - how to add the seed? [on hold]

I use a diskless web server with a live cd and looking for a possibility to restore my electrum wallets automatically by a seed. I would like to implement a script that performs this task for me. so ...
1
vote
1answer
30 views

Get first/second file column

I have two for loops here for i in $(cat "firstFile.txt") do for j in $(cat "secondFile.txt") do if [ "$i" = "$j" ]; then echo $i[$2] # use first file second column ...
4
votes
1answer
104 views

Redirection to file does not work properly

I have here a bash script: #!/bin/bash TARGET_FILE=ping_result.txt # declare the target ip addresses declare -a ips=("XXX.XXX.XXX.XXX" "YYY.YYY.YYY.YYY") function print_and_log() { echo "$1" ...
2
votes
1answer
36 views

Using nice on bash (or other) subshell?

Say I'm working on a sluggish system and notice (say via top) that CPU usage is up around 100%, but I don't want to kill the process. If I want to do other work on the machine and just make that ...
0
votes
0answers
20 views

output in columns [duplicate]

i am trying to put my data after a snmp walk in a table this is my code: for i in `cat $Rep_Scripts/IP_ALU_LIST.txt | awk '{print}'` do read hostname ip <<< $(echo $i |sed 's/;/ /') ...
5
votes
3answers
319 views

Compare the heads of two files in bash

I can do diff filea fileb to see the difference between files. I can also do head -1 filea to see the first line of filea or fileb. How can I combine these commands to show the difference between the ...