Bash is the shell from the GNU project. It is the standard shell on many Linux distributions and often available on other *NIXes.
2
votes
2answers
33 views
How to check if EDID can be tusted
read-edid gives me the message "The EDID data should not be trusted as the VBE call failed". Thats okay, but I want to find out, that this data is not reliable, another way, because I can't use ...
2
votes
3answers
35 views
Why do 'ssh host echo $PATH' and printing the $PATH after ssh'ing into the machine give different results?
On a particular host, when I ssh into the machine and enter echo $PATH I get
/home/wxy/bin64:/home/wxy/bin:/usr/kerberos/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin
and if I ...
5
votes
7answers
207 views
How to test whether the file is crlf or lf without modyfing it?
I need to periodically run a command, that ensures that some text files are kept in linux mode. Unfortunately dos2linux always modifies file, which would mess file's and folder's timestamp and cause ...
6
votes
3answers
70 views
Split an existing prompt command line in a few lines
I understand I can type \ enter at the end of a bash command line to continue that command in another line. But how can I split a prompt command line — that has already been fully typed — into two?
...
1
vote
1answer
38 views
Augeas in shell script
I'm trying to use augtool in shell script ex:
#!/bin/bash
augtool <<-EOF
print /augeas/load
EOF
However if I execute this script, the script will run indefinitely with no output and the CPU ...
-3
votes
1answer
45 views
“not a valid identifier” when I do “export $PATH”
When I run export $PATH in bash, I get the error not a valid identifier. Why?
Here's my ~/.bashrc file
# ~/.bashrc: executed by bash(1) for non-login shells.
# see ...
3
votes
1answer
69 views
How to trigger error using Trap command
I am using Ubuntu 12.04.2. I am trying to use "trap" command to capture abnormal or error in my shell script but I am also trying to manually trigger "Error" exit.
I have tried exit 1, but it won't ...
2
votes
3answers
68 views
Shell: How do I get the last argument the previous command when it was detached?
Within the shell, typing ALT+. or using !$ recalls the last passed argument of the previous command. I use this all the time, but how do you do that when you detached the previous command?
$ ...
4
votes
3answers
52 views
bash history - ok to use file from old machine when setting up new machine?
I love my bash history. Sometimes I've issued really long commands and I really depend on my bash history to get them back quickly. I've increased my history size with:
HISTSIZE=100000
...
10
votes
2answers
155 views
Symbolic link recursion - what makes it “reset”?
I wrote a little bash script to see what happens when I keep following a symbolic link that points to the same directory. I was expecting it to either make a very long working directory, or to crash. ...
-2
votes
0answers
46 views
Copy directory onto multiple servers using a bash script
I have a local directory I need to deploy to 300 servers. What's the easiest way to write a shell script that mass-copies it to all of them?
0
votes
0answers
26 views
Easy way to push data into MongoDB from Bash shell script?
I know you can create a Javascript file that the MongoDB shell will execute upon startup. But I'm hoping for something more "lightweight" than that. I am using a Linux program that has a scripting ...
6
votes
2answers
178 views
Executing piped commands in parallel
Consider the following scenario. I have two programs A and B. Program A outputs to stdout lines of strings while program B process lines from stdin. The way to use these two programs is of course
...
-1
votes
1answer
41 views
SED command and filenames with space
I was hacked, for my php files was infected.
Example: http://www.nwww.ma.mk/oscommerce/configweb/apexfash-wp-blog.txt
Bad Code:
<?php ...
0
votes
2answers
27 views
Why are there empty lines in the output of my command?: find ~/x/y/ | shuf > ~/Desktop/z.txt
As it turns out the reason for this problem was one filename with several newlines. (No idea how that happened.)
find ~/x/y/ | shuf > ~/Desktop/z.txt
This command works pretty much as expected ...
0
votes
1answer
37 views
MAC bash commands stop working properly
I was trying to install some stuff for scala development on my MAC, and probably I managed broke the shell/terminal while I was mindlessly running some scripts that I don't know.
Now when I start the ...
1
vote
2answers
47 views
for loop to get more than one arguments
In python and some other programming languages, it is easy to get a vector instead of one variable everywhere and in loops. like python:
for variable in ...
4
votes
2answers
41 views
Convert MAC address to Link-local address with bash
How can I convert a Mac address into an ipv6 Link-Local address?
you have to add fe80:: at the start and insert ff:fe in the middle
furthermore all leading zeros must be stripped
0
votes
2answers
57 views
search fitting ipv6 address for MAC-Address in neighbours
I have a list of possible to ip6 addresses converted MAC-addresses, that could be found in the output of
ping6 ff02::1%wlan0
possible mac addresses are for example:
66:70:02:75:80:fe, ...
3
votes
2answers
51 views
how to loop through arguments in a bash script
I would like to write a bash script with unknown amount of arguments.
How can I walk through these arguments and do something with them?
A wrong attempt would look like this:
#!/bin/bash
for i in ...
9
votes
3answers
93 views
When to use redirection to stderr in shell scripts
I know that well-behaved utilities like grep output "normal" messages to stdout, and error messages to stderr.
$ grep '^foo' file1 file2
file1:foo
grep: file2: No such file or directory
When I'm ...
0
votes
1answer
33 views
Expect script within bash & exit codes
I have a bash script that calls an expect script.
The expect script has several conditions. It ssh's into a box and executes a command, and there are different possible errors that could happen which ...
1
vote
3answers
91 views
Test if there are files matching a pattern in bash
I am trying to write an if statement in bash to test whether there are any files matching a certain pattern. If there is a text file in a directory it should run a given script.
My code currently
if ...
1
vote
2answers
37 views
Color PS1 based on previous command output [duplicate]
I have my current PS1 as follows. The $? output is really useful (second line).
export PS1="\
${PSOn_Blue}${PSBWhite}\t\
${PSColor_Off} \$?\
${PSColor_Off}${PSBGreen} \u\
${PSColor_Off}${PSWhite}@\
...
10
votes
4answers
637 views
How do I trigger autocomplete without a tab key?
I'm ssh-ing to my machine using my iPhone with an app called ServerAuditior. It doesn't have tab key. See screenshot.
How do I trigger autocomplete without the tab key? I don't want to type a lot of ...
0
votes
1answer
79 views
How to export variables that are set, all at once?
set command displays all the local variables like below. How do I export these variables all at once?
>set
a=123
b="asd asd"
c="hello world"
1
vote
2answers
66 views
How to export variables from a file?
tmp.txt file contains the variables to be exported, for e.g.
a=123
b="hello world"
c="one more variable"
How to export all these variables using export command, so that, they can later be used by ...
2
votes
1answer
39 views
How can I fix this SSH hostname tab completion script?
I found the following script (for bash) that enables me to get tab completion for any hostname I've connected to (from ~/.ssh/known_hosts):
complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ...
7
votes
1answer
104 views
What are the readline word separators?
When I delete a "word" in Bash, it will stop at certain characters like _ and /. For example, if I type
/foo/bar
and activate backward-kill-word (typically mapped to Alt-Backspace and/or Ctrl-w), ...
1
vote
0answers
13 views
AWS XML response error signature does not match
I have a bash script that should return the XML response for AWS EC2 regions
but I am getting an XML error response as:
"SignatureDoesNotMatch" The request signature we calculated does not match the ...
3
votes
2answers
67 views
Quoted vs unquoted string expansion
for i in $(xrandr); do echo "$i" ; done
for i in "$(xrandr)"; do echo "$i"; done
for i in "$(xrandr)"; do echo $i; done
I understand why 1 differs from 2. But why does 3 give a different output ...
-2
votes
1answer
44 views
I am new to bash shell scripting on Linux/Unix. Can anyone please give me some practical examples to start with [closed]
By some practical examples, i mean such examples which make my daily administration tasks very easy. Mostly i need backup of the files from a current directory, sending files to an FTP server, and ...
5
votes
7answers
103 views
Bash way to check if a process is already running in the background (and skip re-execution based on that)?
Can I make a bash command line that only runs a certain command if the process is not already running (in the background)?
How do I check*, if a command is already running?
(so I can add the next ...
2
votes
2answers
68 views
How can I rename all files with one extension to a different extension recursively [duplicate]
Say I have a folder:
/
/a.bub
/v.bub
/dr.bub
/catpictures
/catpictures/or.bub
/catpictures/on.bub
How can I format a script to change each of these to .aaa.
Here is what I've got, although it ...
1
vote
1answer
32 views
Prompt user for sentence and store it without being disturbed by spaces
I have a bash function that prompts user to input certain data.
I tried it with first name, last name, birthday etc.
Data that is mostly represented in one sentence.
When I ask for street + no. the ...
1
vote
2answers
57 views
Debugging bash functions [closed]
So here I have a simple function that I wish to debug. However, I am unable to debug the desired function even with set -o functrace enabled. Before resorting to asking this question, I had managed ...
1
vote
2answers
68 views
better way to get memfree from /proc and convert to decimal [duplicate]
I'm using awesome wm with bashets to make a little text widget to display the free memory. I wanted to convert the number from total kB to gigs (i.e. 1.2).
this is what I came up with...
...
-1
votes
3answers
83 views
run file from different directory [closed]
I have a directory mainfolder with a subdirectory execution which contains a configure script. I can switch to the execution directory and run ./configure and it works fine. Now I'm trying to figure ...
1
vote
0answers
27 views
why bash history overlap the prompt when scroll up in the history? [duplicate]
I customized my bash prompt, PS1 value.
~/.bashrc:
Color_Off='\e[0m' # Text Reset
BGreen='\e[1;32m' # Green
BPurple='\e[1;35m' # Purple
BWhite='\e[1;37m' # White
...
23
votes
3answers
1k views
Why shouldn't someone use passwords in the command line?
Why do people fear writing passwords in the command line?
The history file is located in ~/.history, so it's available only to the user who executed the commands (and root).
0
votes
1answer
49 views
How can I use a variable from a script?
A bash script is running as I defined it in Startup Applications. It is possible to display on terminal a variable used in that script? If yes, how?
3
votes
3answers
93 views
Fix “firefox is already running” issue in Linux
I am trying to open Firefox in CentOS, but I'm getting the following message:
Firefox is already running but is not responding
and Firefox doesn't open. I tried this in command line:
kill ...
0
votes
1answer
41 views
/etc/bash.bashrc errors [closed]
I am attempting to customize my prompt in Arch Linux which is running on a Raspberry Pi. This is exactly how my bash.bashrc looks. When I try to open a terminal (and that bash script gets run) I see ...
1
vote
1answer
29 views
How can I convert this bash function to the fish shell
I'm trying out the fish shell 2.0 to replace bash. I'm trying to convert the following bash function to a fish function, but its giving me hell. I have a several similar functions so if someone ...
2
votes
4answers
60 views
Bash - Multidimentional Arrays and Extracting variables from output
I am trying to do something simple however I'm not sure how to achieve my goal here.
I am trying to extract the: USER, TTY and FROM values that are given by the w command on the console. In bash I am ...
2
votes
2answers
71 views
Bash scripting - loop until return value is 0
I need to umount something in my script, but sometimes it unmount's before all of the data has finished being copied and causes the umount to fail. I looked for a way to do a "blocking" umount, but I ...
-4
votes
3answers
56 views
Linux prompt missing brackets
I'm using centos in my VPS server and guest system. There're two logins for a guest system. One is root and one is regular. After I mounted the guest system and chroot to the mounting directory, I ...
2
votes
5answers
61 views
Carriage return issue
I have this in a bash script
DAY2="20130605"<Cr>
echo "This is yesterday date:"$DAY2"end"
Why is the output the following? It seems as though there is a carriage return in DAY2 but where is ...
1
vote
1answer
60 views
How can I write a small log with bash?
I'm running applications via PHP exec with bash. My problem is that this creates large log files. I need only the last ouptut I don't need a log of all activity per second.
This is my bash :
%s > ...
2
votes
2answers
24 views
Pass arguments to function exactly as-is
I have the following function:
bar() { echo $1:$2; }
I am calling this function from another function, foo. foo itself is called as follows:
foo "This is" a test
I want to get the following ...



