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
vote
0answers
3 views

Can't copy or view files with hangul

I'm trying to copy a directory of Korean and Japanese music on a Debian Jessie box. The source file system is hfsplus from a dead Mac, mounted with hfstools: # mount -t hfsplus -o ro /dev/sdX /mnt ...
1
vote
2answers
43 views

How is IFS really rendered?

I've read bash manpage and other docs, but I find the explanation a bit confusing. I have the following simple script: #!/bin/bash IFS="" echo $2 var=A B C echo $var if I execute it, eg: ...
-1
votes
1answer
15 views

How to use pass filename without extension to gedit external tool for make?

I am wanting to build and run a program called dbgen using the external tools. I know that this variable holds the filename, ‍‍‍‍‍‍‍‍‍dbgen.c‍‍ : $GEDIT_CURRENT_DOCUMENT_NAME How do I remove the .c ...
0
votes
1answer
31 views

List all file extensions in an arborescence and count number of occurences of each [duplicate]

I am looking for a simple shell function (bash prefered) to list all file extensions in an arborescence and count the number of occurences of each. For example, list_extensions . would return ...
0
votes
1answer
34 views

How can I populate an array in Bash Shell script loop

cmdline> ls -la /.myScript.sh set index=0 set usrlist[index]="null" while read line do #Total lines read z=`echo $line| wc -l` lines=`expr ...
9
votes
3answers
8 views

Why is my Bash script returning a syntax error?

I am writing a script which loops into recent files in a folder and executes a command... #!/bin/bash cd /home/Downloads recent_files = ($(ls -t | head -20)) for file in "${recent_files[@]}" do ...
-6
votes
0answers
29 views

Why changing variable position fixes the error [on hold]

I spent half hour trying to figure out why totusr=`expr $index + $totusr` was giving me syntax error then I did this totusr=`expr $totusr + $index` GUESS what its working.but why ?
0
votes
1answer
50 views

what is shell script? [on hold]

Is that some thing like a programming language? Which does provide this option(facility) by a program running on linux or basic program that comes with linux kernel?
0
votes
1answer
40 views

How can I use sed to print out unique users [on hold]

I wish to print out the unique users in the system using only sed, using: ls -la | sed '/^$USER$/p' .... It gives me all files, matching to the current user, and prints out the lines they are in. ...
0
votes
1answer
19 views

Filtering Log Output on Separate Lines

I did a recursive grep in a directory to find all files that would match as follows grep -ER "match_string1|match_string2" /path/to/dir/ What I get as output is: ...
2
votes
1answer
93 views

bash time with nohup

I want to know how much time it takes to run something in nohup. I know this works: $ time sleep 2 real 0m2.001s user 0m0.000s sys 0m0.001s But why it doesn't work with nohup? $ nohup ...
0
votes
1answer
34 views

doubts in file system hierarchy? [duplicate]

explain the difference between /bin and /usr/bin used in Linux?
0
votes
0answers
25 views

include Forking - Multi threading in bash script to run it in upstart?

I have lack of understanding. Do i need to include forking in my bash script: http://stackoverflow.com/a/26756839/4749164, so i can use expect daemon/fork - option in upstart? i would like to run my ...
4
votes
2answers
37 views

How to kill a bunch of jobs based on ps output?

Here is output from ps $ps aux | grep blob ubuntu 4286 0.0 0.1 34748 9592 ? S Jan14 0:00 /usr/bin/python /usr/local/bin/pynt start_blob_reader ubuntu 4287 0.0 0.1 34748 ...
0
votes
0answers
10 views

Using brew: curl version error, “Incompatible library version” for libcurl.4.dylib

I used to have a working version of homebrew but then something broke today related to curl and libcurl.4.dylib— possibly a version or file location issue. I'm on Mac OS X 10.9.5 (Mavericks). For ...
-1
votes
0answers
28 views

Custom Command not found after sourcing .bashrc [on hold]

I wanted to add a function that could create custom alias so I added the following to .bashrc function addalias { echo "alias $1='$2'" >> ~/.bashrc } I then ran source .bashrc I tested ...
0
votes
1answer
41 views

What's the best way to make a bash function in a script as a parameter when running via command line?

I'm fairly new to bash scripting, and wondered what's the simplest way to make bash script functions in a script as the parameter when run via command line? Example usage: ./myscript function1 ...
0
votes
1answer
37 views

Log output from more than one script

I have a problem concerning the logging of a process: I have 3 scripts, a.py, b.py and c.sh a.py calls b.py and b.py calls c.sh The goal is to continuously log std out/err (write to file and ...
5
votes
3answers
71 views

How to undo changes in the commands-history?

In UNIX systems you can press top and bottom arrows to navigate through the previous commands. This is extremely handy. Sometimes, I go up and find a command that I want to use again, but with some ...
2
votes
2answers
32 views

universal help/man command: help builtin partial matches

I found a nice little script which iterates through a couple of manuals for a specific command. As a last resort, it will Google it and open a browser window. Source here: ...
0
votes
2answers
61 views

How to use 3rd variable in BASH for loop?

Good day. I want to parse data of particular columns from several files(aprilPlate.txt, mayPlate.txt, junePlate.txt, julyPlate.txt, augustPlate.txt) using For loop. The data of input files ...
0
votes
2answers
37 views

How to grep from command line for theses multiple strings?

I need to run a command to grep one of these strings from command line as web host disabled account to run website from browser until virus files are removed and I managed to collect few strings that ...
6
votes
2answers
25 views

How to check from bash if package exists in debian

I would like to make a installation bash script, where I would like to install mysql server. On linux mint I had followed code: apt-get -y --force-yes install mysql-server-5.6 but I installed new ...
1
vote
1answer
29 views

How to write a regex to look for strings with fixed length with at least one occurrence of a character

I've been doing some reading on regular expressions and thought I had everything covered, until recently. I've had to filter out all strings of length 5 which end with the letter t and contain at ...
1
vote
1answer
32 views

Script executes differently if run from udev

I'm having an issue with a script that seems really weird; it appears to stop executing prematurely when run from udev, but not when I run it manually from the command line. I've tried troubleshooting ...
0
votes
1answer
24 views

How to execute several lines into a .txt

I am using SSH; In a folder I have the next files: -rwxrwxr-x 1 german german 48 Apr 29 10:45 prueba.txt -rwxrwxr-x 1 german german 23 Apr 29 10:43 script1.sh -rwxrwxr-x 1 german german 23 Apr ...
0
votes
1answer
36 views

Script for update

I need your help in a script used for update : OLD="int 10" NEW="int 20" i=0 DPATH="/home" for f in $DPATH do sed -i "s/$OLD/$NEW/g" $f let i++ echo "modified:" $f done what i need ...
3
votes
2answers
113 views

kill: SIGSTOP: invalid signal specification error in bash script

When I use kill on command line it works. kill -SIGSTOP 1234 But if I use in bash script file I get this error: kill: SIGSTOP: invalid signal specification sh file is #!/bin/sh kill -SIGSTOP ...
1
vote
2answers
31 views

Dynamically create array in bash with variables as array name

This has been asked several times, but none of the methods work. I would like to dynamically create arrays with array names taken from the variables. So lets start with just one array for now: ...
0
votes
1answer
16 views

How to search for just new data and upload to mysql table,

I'm having a blonde moment. Problem Statement: So I have some timestamped data in a file which constantly at arbitrary intervals gets updated, and I just want to filter out data for the previous full ...
1
vote
2answers
32 views

How can I properly use the 'sed' s command in this particular scenario

There's a very simple question that's been bugging me about the sed command. Reading the documentation about this command has left me confused (mostly because English isn't my primary language). So, ...
2
votes
1answer
38 views

Execute commands from history that match regex or grep

I was wondering if its possible to execute commands from history that match a certain regex? I know you can do something like fc 232 248 And it will go into your history and then do revisions ...
0
votes
1answer
46 views

AWK is throwing an error “unexpected newline or end of string”

My Bash script: declare -a lang=('english' 'spainsh') sms="Free msg: Due to upgrades on apps you’ll need a new version by yyyy/mm/dd to app running. Visit a store or go to" url="google.com/UA2392 ...
0
votes
2answers
51 views

How to extract unknown arguments within a shell script?

I have a shell script that accepts a variety of options, some with arguments, some without, some short, some long. It should handle some of these options itself and pass on the rest it does not know ...
1
vote
1answer
41 views

How can I prepending a character for every output of a command?

I'm running commands which I want to specifically group them by every command, as shown in the example below. Tried printing with echo -e '| $line' but it only affects commands that output the text ...
3
votes
1answer
147 views

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

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

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

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
6answers
51 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
206 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
22 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
47 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
164 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
152 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
18 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 ...
3
votes
1answer
32 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
277 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
296 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
21 views

Duplicate Image Searcher using Bash [closed]

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
323 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 ...