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

learn more… | top users | synonyms (1)

1
vote
1answer
34 views

Extract icons from EPS file

I've got a grid of icons, stored in EPS file. There is something like 80 icons in there. I need to extract them from the file. Is it possible using imagemagick or something like that, without ...
2
votes
0answers
57 views

How do I force nmcli to reconnect to different uuid?

I have a bash script that checks my network environment and mounts shares accordingly. If I'm at work and have a hard-wire connection to the LAN, then I'd like to activate a hotspot connection for ...
3
votes
1answer
196 views

Stop/kill running script if $USER != “root”

I'm working on a scripts that needs to be executed as root, else it should stop everything. #!/bin/bash validationRoot() { if [ $USER != 'root' ] then echo "You're not root! ...
0
votes
1answer
37 views

compile a fortran code in an other server

I am a beginner in Linux. I have a Fortran code that I can run it in my own server,but when the same package is copied to an other server,it is not work. in my server i type this in terminal program: ...
0
votes
1answer
30 views

Can somone help me make this script more readable?

SRC="/src" export DEST="/dest" find "${SRC}" -iname '*' -type f -exec bash -c 'EXT="${0##*.}"; EXT=${EXT,,}; if [[ "${EXT}" == *"/"* ]]; then EXT="no_extension"; fi; mkdir -p "${DEST}/${EXT}"; rsync ...
0
votes
0answers
18 views

How to assign disk usage into a variable

Im new to creating shell scripts and i am trying to create a script that counts disk usage and display its percentage value.For example : "disk usage :2.8 GB , free space : 48 %" Here is all i could ...
1
vote
1answer
11 views

Facing error in recursive function for deriving factorial of a number

I have written the following code to derive factorial of a given number. Being newbie to Shellscript, I used normal C code logic of recursive function. #!/bin/bash #This script will do factorial of ...
0
votes
1answer
23 views

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

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 ...
11
votes
4answers
493 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
40 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
31 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
38 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
49 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 ...
3
votes
2answers
50 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
26 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
40 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 ...
9
votes
5answers
560 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
24 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
61 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
14 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
57 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
37 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
27 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
45 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
77 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
32 views

Set custom added PATH vars to work in each Terminal session [duplicate]

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 ...
1
vote
3answers
90 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
33 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 ...
14
votes
5answers
915 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 ...
11
votes
2answers
618 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
64 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
40 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
42 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 ...
30
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
237 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
24 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
365 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 ...
-2
votes
1answer
75 views

Can't type letter 'm' in bash [closed]

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
20 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
18 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
22 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
73 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
69 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 ...
0
votes
2answers
154 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
652 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
144 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
19 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
45 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
36 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
43 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. ...