Bash is the shell used in Ubuntu's command-line interface.
1
vote
2answers
36 views
How to see available commands that end with a certain string?
If you start typing and pressing tab the console tries to expand and show all commands, functions and executable scripts that begin with what you have started to write.
Is there a way to see which ...
5
votes
1answer
57 views
How to get select statement choices into If statements?
I'm very new to programming on Ubuntu. And I'm trying to do a simple bash script.
I have a select menu working but I want the choices made in that to go into a number of if statements, corresponding ...
3
votes
1answer
56 views
Locale warning while executing adduser
I just tried to add an user to a group
$ adduser someuser sudo
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = ...
1
vote
1answer
35 views
Can I create a new script and chmod it in one command?
When writing answers on here, it's often necessary to create a new script and chmod +x it to make it executable. I won't go into whether this is a good thing or not, but explaining to people that they ...
0
votes
1answer
101 views
Open file with terminal and close terminal afterwards
I want to open a file using the terminal on ubuntu.
To have it independent from the terminal, I use gnome-open:
gnome-open text.pdf
And since I'm lazy, I also have this alias in my .bashrc:
alias ...
1
vote
1answer
39 views
Bash escape from script
I have a simple app launcher script used to open a few apps in a ceratain folder on a certain workspace:
#!/bin/bash
if [[ -n "$2" ]]
then
wmctrl -s $2
fi
terminator ...
1
vote
1answer
32 views
Can't redirect all output of program
I am attempting to redirect all output of a program (Steam) to /dev/null so it doesn't show up in the terminal.
Here's what I've tried:
steam & > /dev/null 2>/dev/null and steam & > ...
11
votes
1answer
165 views
Bash comparison and expression operators
I'm new to bash programming. I've read two good, long guides, but they made a mess in my head about operators and keywords.
Which are more commonly and widely used? I don't know when to use which ...
2
votes
1answer
44 views
awk quoting program text
I just came across a gotcha in awk, and I would like to know if anyone can explain to me why this happens.
The following 2 lines behave differently if I run:
# grep -Rl BASE_DIR --exclude-dir=.svn * ...
0
votes
0answers
11 views
Permissions depending on parameters passed to application
I have a java app that writes to a very important table I have. This is sudo protected, but this app takes a parameters for where the output should go. The default is the REAL DEAL but the "output" ...
1
vote
2answers
65 views
Deleted /bin instead of /android-project/bin
An android project has its /bin directory and what I wanted to do is to deleted this. What I actually mean is delete /path/to/android-project/bin not the /bin directory.
So I executed this command,
...
0
votes
0answers
27 views
Bash script that convert any output (text) to json form
I want to create bash script that it converts output of other scripts (Normally simple text) in a valid json form. How can I do this ?
Example:
awk '/^Mem/ {printf("%u%%", 100*$3/$2);}' <(free ...
0
votes
2answers
84 views
Why is setting alias in .profile not working?
I have this as the last line in my .profile:
alias gl="cd /home/jrenner/glances/glances"
yet even after reboot I get command not found when typing gl. What is happening? I am logged in as the ...
0
votes
1answer
58 views
Problem sourcing variables inside Upstart
I'm trying to use the variables defined in /etc/environment in an upstart script running on 12.04.
I'm able to export the variable to the child process but for some reason I not able to use them in ...
1
vote
2answers
74 views
killall doesn't kill all and rarely kills, what is the command for then?
I occasionally use the killall command to kill processes. The reason why I say ocassionally is that in some cases it hasn't worked for me.
A recent example was with thunderbird where there were about ...
0
votes
2answers
103 views
How to pause a running aria download
When downloading big files it necessary to pause the download many times. A big file can be downloaded by using wget. First start download, then kill wget, then resume download by wget -c.
I want to ...
0
votes
1answer
189 views
how to use expect with bash
I Have created a shell script as given below.This script will login to a remote server as a normal user then switch to root user for creating a directory.The script is as given below.
ssh -t ...
6
votes
1answer
126 views
VLC “:rate=2.0” - Where do I put this in command-line?
I figured out a way to transcode my videos so that they would play at double speed using the GUI as "Convert/Stream" --> "Show More options" and adding ":rate=2.0" after ":file-caching=300" in the ...
1
vote
1answer
76 views
How to use ' and " (quotes) as an argument
Intro
In a script I want to run a command in a separate window so that output of the command will show in a new window (which is an output stream like top) and they do not interfere each other. For ...
2
votes
1answer
40 views
Permission Issues with command in rc.local
I am using a command to start a screen session and run a bash script for a user.
/bin/su username -c "/usr/bin/screen -dmS test bash -c '/home/username/test.sh; exec bash'"
When I boot, I am seeing ...
15
votes
2answers
514 views
Bash: delete from cursor till end of line with a keyboard shortcut
Consider the following bash prompt, where ^ denotes the prompt location:
# git commit -am "[bug 123456] Do this and that with the bug"
^
Suppose that I want to commit ...
2
votes
0answers
41 views
Running bin file in bash script [closed]
I want to build a bash script that runs a bin file.
However the question is:
how to continue the script even after bin operation is completed to perform other commands?
3
votes
2answers
78 views
How do I run a py file with pico in the terminal?
I got this when I tried to open a .py file on the terminal line I edited in pico:
lightning@rigel5:~$ ./hello.py
bash: ./hello.py: Permission denied
How can I easily open a .py file from the pico ...
3
votes
2answers
62 views
Copying from mount share drive to local folder through script
This is my first time trying to work with Linux Scripts so this may be something obvious.
Here is what I am trying to do:
Remove all contents from local folder - rm /home/user/Documents/Exercise/
...
2
votes
2answers
45 views
How to port the bash settings?
I want my own bash environment vim tmux and so on, that I can customize for my develompment needs. Then upload it to github and install whenever I set up my computer new.
Any HowTo's how to proceed?
2
votes
2answers
34 views
Using read without losing the TAB
Im using read in a while loop to automatically change a makefile after download.
Here is part of the script,
while read a; do
if [[ "$a" = "FCOMPL=g77" ]]
then echo "FCOMPL=gfortran" ...
2
votes
1answer
153 views
Why does “if [ 0 ]” execute the “then” statement in bash script?
This guide says:
An if/then construct tests whether the exit status of a list of commands is 0
If I execute 0 in the bash, it says:
0: command not found
So its exit status is not 0, and [ 0 ] ...
1
vote
0answers
45 views
How to create a bash file allowing a folder from CD be transferred to Documents?
i want to transfer the myfiles folder from CD to Documents in a more decent way of transferring. I think creating an executable bash file is better. this bash file when clicked will allow the ...
6
votes
3answers
183 views
Replacing dots (.) in sed
I have a string of text:
" . . ."
that is
space dot space dot space dot
I am trying to replace all occurence of this string in text file to
"..."
that is
dot dot dot
I was trying to ...
3
votes
1answer
108 views
Saw an interesting command but can't alias it
Saw an command from this post http://askubuntu.com/a/266839/75967 that I would like to alias
find {,/usr}/{,s}bin -printf '%f\0' | xargs -0 whatis | sort | less
I assume the less or the | is ...
0
votes
0answers
29 views
Create bash with xinetd
I'm making an intentionally vulnerable Ubuntu server for an information security class. I'm trying to create a bash shell that is accessible without authentication, a user should just be able to ...
0
votes
2answers
91 views
Fix bash_profile to Develop Ruby on Rails Apps
I just installed Ruby and Rails stuff on my machine, and start to learn.
But every time I close the Terminal and re-open it, I have to re-type the command . ~/.bash_profile in order to run Rails ...
0
votes
1answer
130 views
Command line FTP download latest files
I am trying to use the command line ftp to download files from a specific date and onwards. Is there a simple solution for this? Thank you!
0
votes
1answer
42 views
Does adding a folder to your classpath add sub-folders?
I am doing this in a script:
if [ -d $SERVICE_HOME/../config ]; then
CLASSPATH="$SERVICE_HOME/../config:$CLASSPATH"
fi
And the /config folder has sub-folders in it also, will files in the ...
3
votes
2answers
71 views
How to run a bash .sh after starting a program in PlayOnLinux?
I have a little script that needs executing every time I open a wine program. The script is pretty simple:
#!/bin/bash
xdotool windowmove 67108871 1440 0
How do I get PlayOnLinux to run this script ...
2
votes
3answers
402 views
Minecraft server (Bukkit) .sh bash file not opening
My Minecraft server (Bukkit) .sh bash file is not opening! I did make it executable (in permissions, I clicked "anyone" for executable). Here's the code:
#!/bin/bash
cd "$( dirname "$0" )"
java ...
0
votes
2answers
168 views
Inserting variable into sed command in bash script
I have text file similar to this:
Some-text
Keyword
Some-text
Some-text
Keyword
Some-text
Keyword
Keyword
I want to replace every "Keyword" with "number.extension" where number is 1 at first ...
0
votes
0answers
70 views
Auto-mount usb flash drivers for remote servers using bash file for scheduled backup operation
I have to do scheduled backup of servers' databases using a cronjob for the backup task and a bash script for the backup operation. It's a PHP web application. You can choose to store your backup file ...
3
votes
2answers
143 views
How can I shorten the bash prompt's current path to one letter per directory?
I can't remember where, but I've already seen the bash prompt's current path shortened in an interesting way: every directory contained in the path is replaced by its first letter only. For instance: ...
0
votes
1answer
62 views
Bash command: ls -lah not showing /etc directory?
Ok guys, elementary question.
I was poking around my server, and I noticed that when I 'ls' the / directory, /etc folder is not displayed. Why is that? I can very easily cd into it, but why is it ...
0
votes
0answers
17 views
PATH variable for sudo [duplicate]
I tries to add some path to the PATH variable. first of all , I added them at the end of ~/.bashrc that only works for the current user and doesn't work for root. then added the same lines into ...
0
votes
1answer
80 views
bash script : is it possible to recognize video format from files (to batch extract audio from them)?
I have written a little bash script to extract audio from video files in batch mode.
Sound is extracted from each mp4 file to flac format using avconv (and the flac codec).
#!/bin/sh
#
# Batch ...
3
votes
4answers
239 views
Bash script not executing from crontab [duplicate]
I have the following bash script:
#!/bin/bash
mysqldump -u ******** -p******** --all-databases | gzip > /home/srvlinux01/MySQLBackups/database_$(date +\%Y-\%m-\%d).sql.gz
which is located in ...
9
votes
2answers
252 views
Why does the sequence matter in the execution of these bash commands?
There seems to be some inconsistency that I am not able to understand regarding the bash shell.
If I execute:
ls;date;time
the results of the three queries are shown in sequence.
However, on ...
17
votes
3answers
335 views
Switch terminal output language from native language to english
How can I switch the terminal output language from my native language to English, so I can post my Ask Ubuntu question with English terminal output (error messages)?
3
votes
2answers
255 views
How do I gvfs-mount without opening a file manager window?
I like to have my devices mounted in Nautilus/Nemo by default when I log in, so I can have symlinks to certain directories.
And I don't mean a custom mount or a mount with 10 lines of cryptSetup and ...
1
vote
1answer
56 views
Configure Fail2Ban with bash script
I'm trying to configure the /etc/fail2ban/jail.local config with an bash script. I was thinking to use sed and regular expression to change the sections I need.
sed -i "s/^bantime = 600/bantime = ...
0
votes
1answer
239 views
Just installed Ubuntu on my Nexus 10… how do I get to a bash terminal?
I just installed the Touch preview on my Nexus 10. It is not at all what I expected. I thought it would be just like my desktop; I'm not at all interested in the "experience"... all I want is a bash ...
3
votes
1answer
68 views
How to evaluate an arithmetic expression in an “if” statement?
This is my script:
#!/bin/bash
num=1
while [ $num -lt 100 ]
do
if [ $num % 3 -eq "0" ]
then
echo "fizz"
elif [ $num % 5 -eq "0" ]
then
echo "buzz"
elif [ $num % 3 -eq "0" ] && [ ...
2
votes
1answer
63 views
Delete lines starting with pattern from a file
I tried several commands: tr, sed but to no avail. Here's the file:
> ...
> ...
> setEPS()
> postscript('images/boxplot_default.eps')
> ...
> ...
I want to delete those two ...




