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

learn more… | top users | synonyms (1)

1
vote
2answers
97 views

Why can't I pipe into cd?

Why can't I pipe stuff into cd? Example: $ pwd >> ~/mloc $ cd / $ tail -n 1 ~/mloc | cd cd fails. If do: cd $(tail -n 1 ~/mloc), it works. I understand the last command I wrote works, but ...
0
votes
3answers
83 views

Why does my condition always evaluate as true?

I'm writing my first bash script and I've hit a snag. Here's an example where I ask for a name, ask for an age, and display a message that changes depending on whether or not the age is <= 35: ...
0
votes
0answers
164 views

crontab doesnt upload file via ftp script

I Write script that make a zip file with /var/www Directory And mysqldump db And upload it via ftp And change mode to executable file And put It in cron tab but file doesn't upload !!! #!/bin/bash ...
0
votes
4answers
91 views

how to pass array into function and updates to array are reflected outsite function

I am trying to pass a array into a function and whatever changes made to the array is reflected outside the function function update_array() { ${1[0]}="abc" # trying to change zero-index ...
1
vote
2answers
83 views

Declare an array but not define it?

There are a lot of guides out there which show how to declare and define an array foo[0]=abc foo[1]=def What I am trying to achieve is to declare an array but not define it because it does not ...
11
votes
5answers
2k views

What does >> or double Angle brackets mean? [duplicate]

It seems like such a simple questions but I cant find any resource regarding it In C/C++ , it means to store the read in a value from command prompt and store it inside a variable , How about in ...
2
votes
1answer
43 views

Compressing many folders

I have a directory containing plenty of folders as well as compressed files. I need to compress the folders that are not already so (tar -cvzf ...) but have no experience in sh scripts. Can anyone ...
2
votes
1answer
124 views

Bash one-liner to delete only old kernels

I've seen lots of threads on how to free space on the /boot partition and that is my objective as well. However, I'm only interested in deleting old kernels and not each one of them but the current ...
0
votes
1answer
90 views

How can I get the bash $RANDOM in a makefile?

This works on OSX: RANDOM := $(shell /bin/bash -c "echo $$RANDOM") test: echo $(RANDOM) For cross platform random numbers I've instead resorted to this: RANDOM := $(shell od -An -N2 -i ...
-1
votes
3answers
861 views

Writing a bash script to copy all files between user specified directories! [closed]

I need a shell (bash) script that can copy all files from one directory to another; where the source and target will be specified by the user calling the script. Could someone help me with this?
0
votes
1answer
221 views

bash: /home/gaja/.bashrc: line 4: syntax error near unexpected token `('

When I open the Terminal I got the following the errors. bash: /home/gaja/.bashrccu: No such file or directory bash: /home/gaja/.bashrc: line 4: syntax error near unexpected token (' bash: ...
0
votes
1answer
107 views

Shell script while statement

I am making a script (for educational purposes) but I am kind of stuck here.. The program asks for an existing filename and checks if the filename actually exists. If it doesn't the loop repeats ...
0
votes
0answers
25 views

E: Sub-process /usr/bin/dpkg returned an error code (2)? [duplicate]

I installed lamp using the command sudo apt-get install lamp-server^. After that whenever I open the terminal the following error appears: bash: /home/gaja/.bashrccu: No such file or directory ...
0
votes
2answers
2k views

bash: No such file or directory

I've written a simple C program that uses the GTK+ visual interface (I can post the code if it's relevant). I can compile it without erros or warnings using: gcc -c s9p2.c pkg-config --cflags ...
1
vote
1answer
50 views

How do I switch desktop session users from a shell script?

I've got 2 users, foo and bar. Currently if I'm logged in as foo, I can select bar from the menu in the top-right of Unity, and since bar has no password set, I switch straight to bar. However, I ...
0
votes
0answers
56 views

iHeartRadio - Looping for changed Auth Code

I have a bash script I'm running that plays a station from iHeartRadio in the CLI. I also use it to record a show in the early morning on my RaspPI so I can listen later in the day. The script works ...
0
votes
2answers
49 views

Is there a tool or trick to help with quoting madness?

When doing server maintenance, I often find myself writing multi-level nested commands, so as: for server in A B C; do sh -c "ssh $server 'mysql db -e \"select where line like \\\"%abc%\\\"\"'&"; ...
1
vote
2answers
489 views

Execute sh script from *.desktop file?

What I want to do at all, is that: Create script that has icon on it. So I know only one way - file.desktop file with icon. Settings icon on it was successful, but I have no luck setting EXEC value :/ ...
2
votes
1answer
72 views

How can I get a variable from terminal to use it in my script?

I'm writing small programs that are allowing me to do common commands with just two or three words max like sudo apt-get update I made it upt something like that Now I'm trying to write a script ...
1
vote
0answers
30 views

.sh Help Please. Trying to convert this to .bat [duplicate]

I have a .batch file with switches and parameters how would i run that in a bash file? Any help would be appreciated @echo off title runserver "C:\Program Files\Java\jdk1.7.0_25\bin\java.exe" ...
3
votes
2answers
85 views

Terminal closes after entering a non-existing command

This seems to be a bug, but i'm not sure which package to report it on. Try this: Open gnome-terminal shift-ctrl-t (open a new tab) type: foo foo & The tab is closed Correct behavior would be ...
1
vote
3answers
438 views

Customize the command shell default prompt

Need help to change the command prompt. I want short name. Look below : kirti@kirti-Aspire-5733Z:~$ cd workspace kirti@kirti-Aspire-5733Z:~/workspace$ cd Ruby ...
0
votes
1answer
35 views

Cron Script Length

I have a backup script, a script that cyncs file with other files on my computer, and a script that uploads files to my website with ncftp. I used cron to load .sh files, and my shorter scripts work, ...
0
votes
2answers
58 views

ubuntu terminal & operator

What does the following command do: COMM1 & COMM2 and how is it different from: COMM1 && COMM2
4
votes
2answers
141 views

Using IFS to handle whitespace in filenames

In question How to rename all files in folder with name ending with "_backup" @Radu Rădeanu gave a good answer that was useful to me as well: find . -type f -name '*.jpg_backup' -print0 \ | ...
0
votes
2answers
70 views

svn post- and pre- commit hooks don't work when subversion gets commited

I have no idea how to fix it. I wrote a simple bash script which writes current date and time to the file, and put it to the post-commit and pre-commit hook. When I run this locally typing eg. ...
1
vote
1answer
1k views

bash: echo: write error: No space left on device

I am using Ubuntu Linux and using this as PHP server hosting the scripts and sites in /var/www/. I am getting bash: echo: write error: No space left on device but there is huge space left on the ...
0
votes
3answers
85 views

How can I change my command line (bash) prompt?

i'm new to ubuntu .presently i'm using ubuntu 12.04 version.I want to know how to change terminal's displaying text. currently my terminal displaying the text.. narasimha@narasimha:~$ how can i ...
1
vote
3answers
142 views

Detecting the name of a network device in bash?

I'm trying to drum up a hack that will output the name of active network devices on one's computer via bash. I'm making it for work. How do I go about doing this? I don't want to just plainly use ...
0
votes
1answer
31 views

Basic question on how to read files in a directory

This is a beginner question: I'm trying to write a .sh file to automatically rename files in a directory. The file would look something like for fileName in directory do mv fileName ...
0
votes
2answers
102 views

Problems with sudo inside shell script

I want to make a shell script to run VI with sudo if I try to edit a file that I don't have write permissions and for that I created an alias alias vi=my_script.sh #!/bin/bash file=$1 ...
3
votes
1answer
128 views

What is the simplest command line instruction in Ubuntu to export a directory file list to a text file?

There is a folder consist of some different file types which most of them are font files. I use this simple command to export file names of Fonts folder to Output text file: ~/Fonts$ ls > ...
0
votes
1answer
180 views

How to replace strings in file without regex?

I need to replace some strings in files (from command line) but I don't want to use sed -i because my string contains lots of funny characters which need to be correctly escaped. Is there a way to ...
1
vote
1answer
64 views

keyboard behaves differently under bash

When logged to other computer from windows under bash, putty maps keys properly but under other shells like sh or zsh keys like Delete are mapped incorrectly (to ~ character). Setting XTERM to ...
0
votes
1answer
95 views

Why environment variable disappears after terminal reopen? [duplicate]

I've tryed to add environment variable in terminal: loom@loom:~$ export DOOM=/home/loom/doom/ loom@loom:~$ echo $DOOM bash: /home/loom/doom/: Is a directory Then I've closed terminal and reopened ...
0
votes
0answers
52 views

Ubuntu startup and shutdown

I have an Ubuntu machine with IBM Websphere and SoapUI I use SoapUI to run a MockService and Websphere to load some web applications and services. I want my machine to shutdown at 23:59 and to power ...
0
votes
2answers
40 views

Can you preview the effects of a command?

How can you preview the effects of a command? For instance, if I want to run rm -r ./*, or chown -r ./*. Is it possible to run a safe "test" of that command with the ability to ensure that nothing ...
0
votes
1answer
741 views

Double-click on .sh file to open terminal and execute series of commands in it?

I'm trying to double click on a file that does this: #!/bin/bash #Mount USB Jump, Copy files to it, Unmount it. [open terminal (so that I can see what 's going on)] pmount /dev/sdc JUMP sleep 2s cp ...
0
votes
1answer
300 views

Write script to open browser at specific URL on login?

I've been using Ubuntu for a few weeks, and I want to know more about automating tasks. How can I write a bash script to open a web browser with a specific URL after startup?
0
votes
1answer
26 views

autogenerate javascript from mysql

I have a site where I can upload images with some info (startdate, enddate, duration, url) I want to make a SlideShow that choose those pictures that is > $startdate && < $enddate. And I ...
2
votes
3answers
152 views

Can't install .sh file

OK, I know there are over 100 questions on this forum just like this one, I know because I've read every one of them, with no luck. I have downloaded a .bin file, extracted the contents into a folder. ...
0
votes
2answers
76 views

Bash : colored copy / paste

As everybody, i have a few colorized output in my bash. I want to keep the colorized syntax when copying an extract to a HTML editor for example. Is there a way to handle this ? Thanks.
0
votes
2answers
184 views

cron error: bad username

I've basically re-written the terminal output instead of appending a series of edits to this question: root@doge:/etc/cron.d# root@doge:/etc/cron.d# tail /var/log/syslog Dec 21 11:35:01 doge ...
1
vote
2answers
116 views

Checking if vim is installed successfully in Ubuntu 12.04

I am a newbie in linux,maybe it's a silly question but could not make it though. I have ubuntu 12.04 installed without GNOME and now as i wanted to know more about linux am facing few queries. I ...
1
vote
1answer
48 views

Files access/modified in a process/script

I will be getting some shell scripts that I, kind of, dont know what they will be doing. But I need to know what I/O operations the script performs (e.g. files they read/access,files they write, ...
0
votes
2answers
85 views

Logging of commands executed in Bash

Sometime back, we had a requirement to log commands run on the terminal in the Bash shell. This was solved by means of a startup script with essentially the following contents: #!/bin/bash ...
1
vote
0answers
45 views

Login errors in .bashrc in 13.04

I just upgraded to 13.04, and suddenly I get xsession errors in my .bashrc on login. There is nothing wrong with the .bashrc file--I can source it from a terminal login, and after I get into the ...
1
vote
1answer
102 views

How to sed two words in a line and add before and after?

I was curious to know if there is a better way to sed two words and add a line before and after them. I learned how from grymoire but I wanted to know if there was a better way to do: #!/bin/sh ...
0
votes
2answers
664 views

How to add the logs to a crontab with time stamp

In crontab, I scheduled a daily backup script. Now when the cron executes the script the status are logged to a log file as shown below. 0 0 * * * /home/backup.sh > ...
0
votes
1answer
120 views

Start Terminator via shell script in broadcast mode

I currently use a small script to start a terminator window as a background process which has multiple splits specified with a layout. terminator --layout=My_layout & I want to execute a ...