Bash is the shell used in Ubuntu's command-line interface.

learn more… | top users | synonyms (1)

0
votes
1answer
15 views

How do you create a Bash Script for replacing text in a document, utilizing regular expressions?

Identical to this question: Find and replace text within a file using commands However I want an answer that utilizes regular expressions specifically. So in short: Using commandline; what command ...
5
votes
4answers
149 views

tr: convert apostrophe to ASCII

I'm trying to convert a Right Single Quotation Mark to an Apostrophe using tr. tr "`echo -e '\xE2\x80\x99'`" "`echo -e '\x27'`" < a > b given a UTF-8 encoded file called a which contains this ...
0
votes
1answer
33 views

Run interpreted commands within sudo

The question is how to run generic commands which may contain ; && | < > << >> $ and so on within sudo. Possible solutions could be: To use interpreters within sudo sudo ...
1
vote
1answer
26 views

Run sudo command within directory

Possible solutions could be: Starting interactive session. sudo -s <<< "cd dir ; command" or sudo /bin/bash -c "cd dir ; command" But I don't have /bin/bash /bin/sh /bin/su or other ...
-1
votes
0answers
29 views

Cuttlefish #!/bin/bash not working 0.o

I was running Cuttlefish on Ubuntu 14.04 with 2 scripts to dim and un-dim my screen when AC power changes to battery and reversed. I reinstalled today and can't make the script dimming or un-dimming ...
2
votes
1answer
36 views

Find not removing files in folders through bash script

I'm very new in bash scripting and I'm really stuck on the find method from Ubuntu. I want to search in the folder /opt/ for all folders to see if they are older than a specific date. If they are ...
4
votes
2answers
193 views

How can I auto-hide the launcher via a script, when I maximize the browser?

I was trying to control Ubuntu 14.4.1 Launcher's behavior. I want it to auto-hide every time I have browser window like firefox maxmaized. I found this solution: #!/bin/bash ## Change value of ...
3
votes
2answers
38 views

Emulate mouse click when hitting a key

I am trying to emulate left-mouse-down when Home key is down and left-mouse-up when Home key is released. The reason behind that is my touchpad's buttons are terrible and I like to use the ...
0
votes
0answers
21 views

Bash question with system processes? Stopping and renicing “Java” processes

I play minecraft on linux, and I would like to make a Bash script that does two things. First, I would like it to close the minecraft launcher's process. Secondly, I would like it to renice the ...
0
votes
1answer
20 views

How to auto load source file on bash startup?

I recently installed Ruby Version Manager (RVM) to make use of the command called compass. Initially it was working find on installation, but now I get a missing error: The program 'compass' can be ...
6
votes
5answers
362 views

Add column from one .csv to another .csv file

file1.csv A,,C,D A,,C,D A,,C,D A,,C,D file2.csv A,B A,B A,B A,B desired Output.csv A,B,C,D A,B,C,D A,B,C,D A,B,C,D I've tried using "join" and "paste" to no avail. Is there a bash command to ...
1
vote
0answers
22 views

How to terminate server process?

I just created automation sending an email using a shell script, but it always running and send me an email every sec to my email. I'm using PID and that process name to terminate it, I'm writing ...
0
votes
0answers
20 views

UMS.sh (run as service) on Ubuntu 14.04 won't read configuration file

I'm trying to get my ubuntu 14.04 to run universal media server so I can stream movies to my ps3 (lowest firmware 4.55 unfortunately - unjailbreakable). After much research on the net I was able to ...
1
vote
1answer
11 views

How to make a application/script available from Bash? [duplicate]

If I want to launch a script (let's say in the home directory I have a file called hi.py) I need to specify the full path: python /home/user/hi.py. But when I want to use mkdir I can simply say: mkdir ...
2
votes
1answer
46 views

Shell script to move all images excluding ones with size in name using find?

I have a server backup of a WordPress site that has about 1000 images in the uploads directory. When an image was uploaded through WordPress it would create multiple sizes of the image such as: ...
0
votes
1answer
32 views

/etc/network/if-up.d script with password prompt

I want a script that logs me in when a specific interface uplink was established (university LAN). The thing is I don't want to hardcode my password into the script. Is there any way to prompt for a ...
-1
votes
0answers
13 views

Hadoop gives Error localhost: Error: JAVA_HOME is not set.?

I'm using Ubuntu. I have installed Java Hadoop configured it as single Node. i have also added environmental variable named HADOOP_HOME,JAVA_HOME in .bashrc file. When i was trying to run Hadoop using ...
0
votes
1answer
21 views

How to detect if an OpenVPN connection has disconnected?

I have a machine that is connected to a VPN through OpenVPN. Is there a way to detect if the connection has dropped and run a script in the event of the disconnect?
3
votes
2answers
70 views

Redirecting output to a variable?

I'm interesting in directing the output from two commands to a variable. I don't want the output to be displayed on the screen, but instead assigned to a variable within my script so that I can use ...
0
votes
2answers
27 views

Set custom added PATH vars to work in each Terminal session

I ran these 2 commands simply in the terminal: export PATH="$PATH:/home/milkncookiez/Developer/android-studio/bin" export PATH="$PATH:/home/milkncookiez/Developer/PhpStorm/bin" in the 2 bin folders ...
0
votes
1answer
46 views

shuffle filenames inside a folder and place changes in a text file [closed]

I need to shuffle all the files placed inside a folder and keep track of all changes that have been made in a text file. The generated output will be same set of files with new names like ...
1
vote
3answers
79 views

copy n number of files from one folder to another folder

I have a folder of n number of files. I need to move n/2(or)n/3 files from that folder to any other folder. How to set the value of n so that it will move exact those number of files?
1
vote
1answer
28 views

Bash: what is the meaning of ${parameter##word}

I'm working on bash code and I found a function CheckOtherFiles that I guess is used to check if a file ($1) is more recent from file $WS_ROOT/$NomeVista/COMP/COMP_COMPILE. CheckOtherFiles is called ...
13
votes
5answers
837 views

Is there any default function/utility to prompt the user for yes/no in a Bash script?

Sometimes I need to ask the user for yes/no to confirm something. Usually I use something like this: # Yes/no dialog. The first argument is the message that the user will see. # If the user enters ...
10
votes
2answers
591 views

Why “which” returns none on some commands I can run?

I used which to tell the location of a runnable file. For example, which pwd returns /bin/pwd. However, I found which alias or which compgen etc returns nothing. What are commands like alias? Aren't ...
0
votes
4answers
34 views

scripting chroot, how to?

So I'm looking at: https://help.ubuntu.com/community/LiveCDCustomizationFromScratch and trying the following within a bash script: sudo chroot chroot mount none -t proc /proc mount none -t sysfs ...
0
votes
2answers
33 views

Media Scanner Script

I am a beginner with Bash scripting. I have recently been working on a script to harden Ubuntu computers for a school project. Everything is going well, except that the students are not allowed to ...
0
votes
2answers
38 views

Continous Loops in Bash

I'm interested in writing a program that will get the size of the mail spool file for the user. (The spool files found in /var/spool/mail/$USER on Linux). To do this, I would like to create a ...
27
votes
1answer
1k views

How can I make cowsay say something every time I close the terminal?

I want cowsay to print something like "have a nice day" when I close the terminal. I know I have to have some kind of script, but I'm not even sure how to write a script or how to use it once it's ...
2
votes
2answers
214 views

Run a standard command in bash script

I am writing a bash script to automate several actions: #!/bin/bash echo "Hello, World" NAME="${1}" PATH="${2}" echo $NAME echo $PATH eval "ls" I am going to call ls, ffmpeg and a lot of ...
0
votes
1answer
20 views

Trying to add timestamp to image but keep getting error unknown image property “%[exif:DateTimeOriginal]”

I want to put timestamps on all images in a directory based on the date created/modified. I've seen a bunch of methods like this and this, but they all use the code %[exif:DateTimeOriginal] which ...
3
votes
1answer
337 views

How do I delete all pop/rap music?

I have all the music stored in ~/Music and I want to delete all pop music (or it could be a different genre). I was thinking to look the song metadata to check and see if a song is pop, and then ...
-1
votes
1answer
65 views

Can't type letter 'm' in bash

My current BASH version is 4.2.45(1)-release. I can't type letter 'm' in terminal. Tried using various terminals. Even copy-paste is not working.(Plz Visit this page before u comment)
1
vote
1answer
15 views

Where does /etc/inputrc come from?

I'm just being curious about how or from what package the /etc/inputrc file is generated in an Ubuntu system. I've tried: $ apt-file search /etc/inputrc But it outputs nothing. No package assigned? ...
0
votes
1answer
14 views

unexpected EOF on the last and next to last line while creating alias

I am creating alias in .bash_aliases file in Ubuntu 14.04 with reference of this article I write these alias agi='sudo apt-get install' alias upd8='sudo apt-get update' alias perms='stat -c '%a - ...
0
votes
1answer
18 views

Mercurial no color in commands after doing su

First noticed in 12.04 still persists in 14.04 This happens when to change to a system user (www-data, postgres, etc) and not for a user which has a desktop profile setup. What I have tried: Copy ...
1
vote
2answers
51 views

How to run a shell script with a file argument located in the same directory at the script? [duplicate]

I would like to run a command with an argument placed in the same directory as the shell script, from a shell script. example: my_installer.sh: #!/bin/sh sudo dpkg -i --someflags=abcd blah.deb ...
2
votes
1answer
58 views

Rename all files in subdirecories

I am having a problem writing a script for mass renaming of files in subdirectories. I have a folder with multiple subfolders, and those subfolders have multiple files that I need to rename. This is ...
1
vote
1answer
68 views

UEFI machine doesn't boot Ubuntu through NVRAM bootcatalog. How to fix?

An answer posted here should: Avoid to require the user to download and install additional packages or PPAs. Be as quick and simple as possbile. (I tried boot-repair and it didn't ...
5
votes
3answers
627 views

What is the point of the bash Null-operator “:”, colon?

What is the point of the "null" operator in a BASH script? I understand that it is used as a placeholder following an if command when you have nothing to say, but need a command to allow the program ...
1
vote
2answers
128 views

How to enable tab autocomplete for scripts located in ~/bin?

If I put an executable in ~/bin I can just type the first few letters of the filename and then hit tab to let the shell finish the rest of the name. While this works with executable programs, it ...
0
votes
1answer
13 views

Smartctl script to write zeros

So i have an old hdd that was badsectors and i wrong the following script to write zeros in badsectors that smartctl finds. The question is will this help the read/write errors or it is futile? the ...
0
votes
1answer
26 views

Terminal error (some typo somewhere?) with .bashrc disables all aliases etc

I can't use any of my aliases or custom defined variables in bash. The error when I open the terminal is immediately: : command not found bash: /home/khaverim7/.bashrc: line 6: syntax error near ...
0
votes
1answer
35 views

What damage will an accidental move of /bin do?

Whilst testing a little bash script I've been writing, a little finger trouble led to a directory name variable not being passed in, resulting in a move command being applied to /* . /boot was moved ...
1
vote
1answer
42 views

Recover accidentally deleted function that is loaded in bash

I was editing my .bashrc file (actually a file sourced in there) and added a bunch of functions. I track my home directory in git, but I accidentally did a hard reset before even staging the changes. ...
0
votes
1answer
28 views

Sharing variables between shell scripts [duplicate]

I have a shell script (let's call it parent.sh) which calls another shell script (child.sh), passing it an argument. The child script does some work and sets a value in a variable called create_sql. ...
1
vote
2answers
48 views

How can I run a bash script without affecting the file system?

I am trying to create some soft of a sandbox for linux systems (ubuntu). My main goal is to find out which files are executed by a bash script of my choice, without actually letting it run them. I ...
2
votes
5answers
316 views

Concealing long paths in variables in Bash

I have to move files from one folder to another but they reside in totally different paths. The destination path is so long and complicated that I am not able to remember it. Is there any way to go ...
-2
votes
2answers
52 views

Shell Script to check for subdirectory [closed]

A)I used the following code to get the modified date of a file. But this is also selecting the subdirectories and thus returning an error. How van I fix this. for file in $1/*; do echo `stat ...
0
votes
1answer
40 views

Run script on shell login for all users

I have a script named "als" that parses the aliases in a user's .bashrc file that I'd like to run for any user logging in via SSH. This should display similar to a Message of the day (MOTD) banner. ...