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

learn more… | top users | synonyms (1)

3
votes
2answers
174 views

Shell variable is not working

I'm trying to launch a program through a variable and it reads run.sh fine but it runs into issues when trying to launch the .jar file. Normal running run.sh works fine and it launches the program as ...
0
votes
1answer
62 views

My permanent alias isn't working [duplicate]

Sorry I am new to ubuntu, just installed it. The version Ubuntu 14.04.4 LTS. I finally learned how to install a program called WebStorm and trying to create an alias for it. I tried creating it ...
0
votes
1answer
26 views

Define a variable inside a function [closed]

I am wondering if it is possible to do like JavaScript, calling a variable from a function, something like: function myFunction(variable){ // do some stuff here } Then we call it like: ...
11
votes
2answers
1k views

Can anyone explain why this happens in bash?

$ sudo -iu abc ls -ltr /sites/servers/server_instance/logs/access* ls: cannot access /sites/servers/server_instance/logs/access*: No such file or directory $ sudo -iu abc ls -ltr ...
0
votes
0answers
15 views

Launch a shell script with arguments from Unity “Dash Home” menu [duplicate]

First off, I know about lenses, and am in the process of beginning to write one for this, however this is "lowest hanging fruit" for the interim. My company uses unfuddle to manage tickets (similar ...
1
vote
1answer
80 views

'source' builtin in bash not recognized in cron environment

A user crontab entry that reads: 0 */4 * * * $HOME/postscript/fprogcache-sync works fine. Wanting to add a few environment variables to the cron-job context, I then tried 0 */4 * * * source ...
1
vote
2answers
49 views

How to store file information into an array?

With this part of script I can get a necessary information about files in my directory(and subdirectories). The only information I need is the extension and the size of file. for file in `find . ...
1
vote
3answers
129 views

How to simplify the command : four same structures?

ntpdate 110.75.186.247 >> /var/log/ntpdate.log || ntpdate 110.75.186.247 >> /var/log/ntpdate.log || ntpdate 203.123.48.218 >> /var/log/ntpdate.log|| ntpdate 103.16.199.21 >> ...
0
votes
1answer
37 views

How can i get this script working?

The Script(input.sh): echo "What is your name?" if [[ $1 =~ "*" ]] then read name1 read name2 echo "Are you really "$name1 "??? or" $name2 "?" else echo "Are you really "$1 "??? or" $2 "?" fi What ...
0
votes
1answer
29 views

Bash If Statment help

I have this if statment: if $type = 1 then date +%s | md5 | base 64 | head -c $length >> $name.txt elseif $type = 2 then date +%s | shasum | base 64 | head -c $length >> ...
1
vote
4answers
91 views

In Bash, how to read a file and take each line as incremental variable?

I have a file like below: (list.txt) 127.0.0.1 us 127.0.0.2 uk 127.0.0.3 cn 127.0.0.4 fr 127.0.0.5 ru 127.0.0.6 bd 127.0.0.7 hk I wanted to make an script which will show the user as items to ...
0
votes
2answers
14 views

export doesn't work [duplicate]

test.sh: #!/bin/bash export test_var=1 Run the script, then continue to run the command in the terminal: echo $test_var, I got nothing. Why? Since test_var was exported, I thought I could continue ...
0
votes
2answers
57 views

Password Generator

re-learning bash from being at uni, and making a password generator. I want to be able to output the results to a text file can anyone help? my code so far is: #!/bin/bash #Password Generator ...
0
votes
0answers
11 views

cron running init.d reload and getting exit code of 2 [duplicate]

I am having cron run a shell script which includes this line... /etc/init.d/nginx reload but it is giving me an exit code of 2...What can I do to reload nginx from cron successfully?
3
votes
1answer
187 views

Control C doesn't work in Ubuntu 14.04

In both gnome-terminal and terminator, press ctrl+c doesn't do ANYTHING. It doesn't kill processes, it doesn't cancel whatever's on the current line and start a new one, nothing. ctrl+shift+c works, ...
1
vote
2answers
53 views

Moving from Amazon Linun to ubuntu, now my init script isn't working.

We are in the testing phase of moving from amazon linux to ubuntu for some of our servers. We have a mono app that is run as a service and on the amazon linux box it ran fine. I know that some ...
0
votes
0answers
34 views

Running make on a Makefile returns a file not found error for files that exist in the same directory as the Makefile

So I'm installing the XRT Swift data analysis software. Currently, I am installing CALDB, and I am struggling with running the script to initialize the program. While the guide says there will be a ...
1
vote
2answers
22 views

Sending the {Return} key in a script file? [duplicate]

How can I send the Return key in a script file? I am installing all the PPAs from a script, and while it works, currently the addition of each PPA requires user input of the carriage return. ...
3
votes
2answers
122 views

adding zero to specific location of file names

I have a directory consists of several files. Files name are as follows; 0102920.05o 0203920.05o 0304920.05o .... I need to add "0" for all files after the first 4 numbers like; 01020920.05o ...
6
votes
5answers
796 views

Get one element of path string using bash

I have an ASCII file containing filepaths which I read by running: while read p; do echo $p; done < filelist.txt The file contains filepaths with the following pattern: ./first/example1/path ...
4
votes
1answer
40 views

Why doesn't cp detect '\ ' (backslash+space)?

I was trying to write a shell script to copy files. Here is what I have done. workingDirectory=$(pwd | sed "s/ /\\ /g") Now echo $workingDirectory shows /home/user/Documents/Learning and ...
1
vote
2answers
46 views

/bin/sh, /bin/bash and /bin/dash all broken, how can I install them again

Removed all /bin/sh, /bin/bash and /bin/dash. I cannot install them because dpkg and apt-get need a shell to install and there is no shell available. I'm still logged in and my Ubuntu is still ...
0
votes
1answer
49 views

How do I automatically run a shell script at start up? [duplicate]

Situation: Whenever I boot up my Raspberry PI, I have to enter a few lines of commands to enable an interface. The commands: sudo modprobe batman-adv sudo batctl if add wlan0 sudo ifconfig wlan0 up ...
5
votes
1answer
135 views

Modify the “alert” alias in ~/.bashrc

System: Lubuntu 14.04 LTS I want to know if it's possible to modify the alert alias provided in ~/.bashrc in a particular way. This is the original alert: # Add an "alert" alias for long running ...
3
votes
1answer
52 views

Executing tftp command without entering tftp command line

I want to execute the tftp command without entering into the "tftp command line". I have tried the below commands: tftp xx.xx.xx.xx -c put file1 file2 tftp xx.xx.xx.xx -m binary -c file1 file2 ...
0
votes
1answer
42 views

How to schedule ClamAv to perform a daily scan

I want to schedule a daily scan in my Home directory using ClamAv. Can anybody explain me how to perform such task using a bash script? I don't need to scan mails, just Home directory and maybe other ...
1
vote
1answer
24 views

Who is using an included file?

With 'fuser' I can see which process is using the file. However any included file does not show with 'fuser'. mainfile #! /bin/bash source subfile SomethingInSubFile sleep 60 exit 0 subfile ...
3
votes
1answer
53 views

bash and sh output is different?

I have code to print the simple multiplication table of a given number. When I run it with sh it gives me perfect output, but when I use bash it gives a slightly different output. Can you explain why ...
1
vote
1answer
28 views

shell script error not able to find [closed]

I have this code and i am not able to point out the error. It is simple program to print table of the number given by user. Here is the code: #a function to calculate the table call() { #to check if ...
3
votes
2answers
28 views

Catch user input with alias

So I recently showed my friend the wall command. Now he keeps using it to talk and I regret showing him. I want to make an alias call wall to keep him from using it and to also prank him. I did ...
0
votes
1answer
56 views

Is it possible to provide “if” and “else” syntaxis in Ubuntu terminal? [duplicate]

I was asked to create command which generates one word in terminal, if internet connection is absense, and another one, if it present. For doing that it seems that I need "if" and "else" syntaxis. Is ...
3
votes
2answers
141 views

One liner to convert small text string to PDF

I've been trying to find a way to create a simple PDF page from the terminal that contains only one string, for example, "Prelude". Some background: I use pdfunite to join music charts together into ...
0
votes
2answers
71 views

Problem installing .sh file

I have this file Mathematica_10.0.0_LINUX.sh that I need to install in my Ubuntu 12.04 LTS. I have already, successfully, run chmod +x Mathematica_10.0.0_LINUX.sh. However, when I run sudo ...
0
votes
0answers
31 views

How to run a Script by Autostart? [duplicate]

This is for a VPS running on ubuntu-14.04 64bit. NOT for a Ubuntu PC! i would like to know, how can i run a script on start (i know about the etc/init.d - but i dont know how to make my script look ...
-4
votes
3answers
114 views

How do I list files which have a “s” as first and a “l” as last char with a shell-command?

I'm trying to list files that start with "s" and with "l". The command I'm trying is ls -l *sfa*
1
vote
0answers
22 views

Using checklist in Bash file

I want to create a bash script that do the following: Create a project folder based on Project -- Name this is OK. Create some folders based on user choices --This is the main question Here is my ...
0
votes
1answer
45 views

In which system file does 'export' command make changes?

I installed java-8 using a PPA. After that I gave a command: export JAVA_HOME=/usr/lib/jvm/java-8-oracle I had heard somewhere that this command does temporary changes. But after many logouts and ...
-1
votes
1answer
40 views

Python: create variables using loop [closed]

how can I create a dictionary variables and every variable has an identical number using a loop in python if it is possible? for example: counter=0 for line in {1..5}: counter +=1 ...
3
votes
1answer
67 views

How to run an interactive script before xserver shutdown?

Every time I shutdown or restart my laptop (Ubuntu 14.04), I would like to run a script that checks, whether I pushed my newest code to my remote git repository. If I forgot it, then it opens a ...
1
vote
1answer
103 views

Maven environment variable not working on other terminal

When I run echo $PATH and echo $JAVA_HOME command as a normal user, I get jdk path variables set. But when I run as a root user, the variables are not set there. I copied maven binary folder to /opt ...
1
vote
3answers
79 views

split txt file in half based on pattern

I have a text file which looks like this: train/a/abbey/00000001.jpg 0 ... train/a/abbey/00000999.jpg 0 train/a/abbey/00001000.jpg 0 train/a/airport_terminal/00000001.jpg 1 ...
1
vote
1answer
47 views

Mirror photo directories and reduce file size

I backup our family photos to my home Ubuntu 14.04 server, to a Samba directory at /srv/photos. I want to be able to view them by visiting a web page, to browse through them, and have created a php ...
-1
votes
1answer
50 views

calling bash command in python

i called bash command in python in subprocess.call, and the return should be a number for example 3, and in the output, it gives the number as output, but it doesn't put it in the variables for ...
1
vote
1answer
41 views

Hourly and daily crons are not running

I've noticed that hourly and daily crons are not running, I moved them to crontab, and everything is fine: #!/bin/bash now=$(date) echo 'It is '$now The command line: # run-parts --test ...
10
votes
3answers
794 views

ZSH removed, cannot relogin

So I have install zsh and I didnt like it. so I did apt-get remove zsh From that point I cannot relogin, i click my user.. and then it just go back to the login screen. I can only login with the ...
0
votes
0answers
21 views

bash terminal colors for directories/executables not working

I have colors on terminal but not for filetypes. I have a pretty heavy bash profile and rc: .bashrc- source ~/.git-completion.bash force_color_prompt=yes MYPW='mypw'4.8 Parallel Computing . ...
3
votes
1answer
55 views

Definitive and immediate way to export a path

Assume I want to export a path, let's say FOOBAR and make the changes not only effective immediately and everywhere but also permanent. My goal is to have a list of commands that can be entered ...
6
votes
3answers
219 views

Create a progress bar in bash

How can I create an progress bar with bash? This is my script: #!/bin/bash pass='number1 number12 number13 number14 number15 number16' chk='number14' for i in $pass ; do if [ "$i" == "$chk" ]; ...
0
votes
0answers
20 views

Performance Alerts

Is it possible & how do I, in Ubuntu to setup a performance monitor / event at a certain performance. I want setup a monitor that calls a .SH script on a couple of things the first and major one ...
0
votes
1answer
34 views

Some confusion about nohup

Situation1 command find / -name "*.conf" Ctrl+Z to pause the process Situation2 --- hello.sh --- #!/bin/bash /bin/sleep 5000 command ./hello.sh & Situation3 command ...