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

learn more… | top users | synonyms (1)

2
votes
1answer
123 views

pdsh works well standalone, but doesn't work in script

I am trying to install hadoop via script on my small cluster [introduced in the book: Apache Hadoop Yarn]. I have set up ssh connect without password, and pdsh&pdcp are all fine if I use it alone. ...
1
vote
1answer
27 views

error in running bash script as root

I have a simple shutdown script which i want to run as root shutdown -h +30; echo "succesfull"; I have followed these answer1,2 to make my script root. first I run this command sudo chown ...
1
vote
2answers
3k views

How to stop and remove the docker

I'm trying to remove a docker/images/containers and all stuff which is somehow connected with docker, but first of all I neeed to stop it. While I'm trying to execute this command: docker stop ...
4
votes
2answers
109 views

Can alias command pass arguments?

I want to know if i can pass an argument with an alias command. for example: alias d="dmesg|grep -iw usb|tail -5" Now d will print the last 5 lines. if i want to use d to print a different number ...
0
votes
1answer
22 views

How to maintain a counter across multiple executions of a script?

I have a script with a conditional statement and I want to find out how many times the if statement is executed (no loops in the current script). That is how many times the script got executed. eg: ...
12
votes
5answers
29k views

How to round decimals using bc in bash?

A quick example of what I want using bash scripting: #!/bin/bash echo "Insert the price you want to calculate:" read float echo "This is the price without taxes:" echo "scale=2; $float/1.18" |bc -l ...
3
votes
6answers
298 views

Use bash to extract number from between square brackets

My file looks like this: [581]((((((((501:0.00024264,451:0.00024264):0.000316197,310:0.000558837):0.00857295,((589:0.000409158,538:0.000409158):0.000658084,207:0.00106724 ...
1
vote
2answers
45 views

parsing out in bash

my file looks like this // [297]((((21:0.125204,20:0.125204):0.00994299,(28:0.0790047,(7:0.0146105,5:0.0146105):0.0643943):0.0561423):0 segsites: positions: 1 2 4 6 9 10 45 67 78 89 ...
1
vote
1answer
455 views

Auto backup when USB Drive inserted

If this is not the best place to post this question, can you please direct me to a more appropriate place to post this. What I am trying to do: I have a USB drive, it is fat32 and its name is ...
2
votes
4answers
118 views

Parse lines with specific pattern out of file

I have a file that looks roughly like this : [25]:0.00843832,469:0.0109533):0.00657864,((((872:0.00120503,((980:0.0001 [29]:((962:0.000580339,930:0.000580339):0.00543993 ...
1
vote
1answer
14 views

Find ports locked to process running in the background

Is it possible to find the ports assigned to the process started on the background? I want to start a process and let it run in the background, like ./run.sh & and then see all the ports this ...
0
votes
2answers
74 views

How can I use history command in a bash script?

I try to use history command in a bash script but it didn't work. The code of the bash file: #!/bin/bash # Copy history to file history #cd /media/saleel_almajd/Study/linux/my_scripts/ echo ...
15
votes
3answers
27k views

how to see time stamps in bash history?

Is there any way I can see at what time the commands were executed from the bash history ? we can see the order but is there any way I can get the time also ? Bottom-Line : Execution time in the Bash ...
1
vote
2answers
19 views

Calling Values from a .properties file?

Right now I have a simple script I want to now call a .properties file and then print the results of that file, this is what I have so far #Specific Set Variables SpecficStatus="Pass" #SetVariable ...
0
votes
2answers
28 views

I need to make a batch of users

I had written some code that would allow me to make a batch of users based on a file with usernames in it. But it eventually went from just a few lines to about 50, and I deleted it. There has got to ...
1
vote
1answer
20 views

Can't find an installed program - mathematica

I recently installed Wolfram Mathematica as a .sh file. I ran it using bash and it took me through installation. It said that the installation directory should be /usr/local/Wolfram/Mathematica/10.1 ...
1
vote
2answers
1k views

Bash is abnormal in Makefile!

all, I have found that the same Makefile works well in Mac OS X, but does not work in Ubuntu. The snippet is as following: start: @echo $(seperator) @if [[ "$(PROJECT)" == "" ]]; then \ ...
3
votes
2answers
39 views

grep regex pattern causes unexpected command behavior

I'm searching for lines with $ and consecutively ' or " through this grep in my terminal: grep "\\$('|\")" -rin folder_path After pressing enter the terminal doesn't think the line is complete so ...
1
vote
1answer
19 views

bash expressions

In a bash script I have the following section. if [ "${1:0:1}" = '-' ]; then set -- mongod "$@" fi What does the expressions ${1:0:1} and set -- mongod "$@" ?
4
votes
3answers
32k views

How to separate fields with space or tab in awk

While playing with awk I came to execute: ls -la >> a.txt ; awk {'print $5 $1'} a.txt ; This is giving output like: 53277-rw------- 52347-rw------- How can I get a space between these two ...
1
vote
0answers
15 views

Screen in crontab

I'm trying to run 9 screens windows by crontab, and then, run some codes (basically the same for all of them), but they don't work. The code runs all of 9 screens, but run code only on the first. Aah, ...
0
votes
3answers
177 views

How do I get my shell script to automatically accept prompts?

I made a simple shell script (that I run as root) to download essential apps that I might need whenever I reinstall ubuntu: It looks like this: apt-get install docky && apt-get install geany ...
0
votes
0answers
13 views

Enable Vino Script Help

I have been trying to add and enable Vino to our districts Ubuntu laptops but have come up with some issues that I can seems to find a solution to and i was wondering if you might be able to assist. ...
29
votes
8answers
3k views

Delete all files except files with the extension pdf in a directory

I have a directory that contains the following: x.pdf y.zip z.mp3 a.pdf I want to delete all files apart from x.pdf and a.pdf. How do I do this from the terminal? There are no subdirectories so no ...
0
votes
0answers
27 views

minimal bash-like line editing is supported. Problem after a fresh installation of ubuntu 14.04.2

So I had ubuntu on my NUC. It was great I have to power on and ubuntu start. But I had a problem and I had to reinstall everything. I erase everything and install to have a fresh ubuntu. Everything ...
4
votes
4answers
79 views

Terminal: Avoid repeating directory multiples times to reach files within

I have two files file1.txt , flie2.txt in a directory X. I want to copy those files to my current working directory which is far away from the directory X. so I end up with a command like: cp ...
-1
votes
1answer
50 views

help with my script “path of shell” [on hold]

I usually php but also use bash to automate tasks on my server. I am trying to test this bash script but I'm not sure what "path of your shell" means. If anyone could help me with what i am meant to ...
0
votes
2answers
3k 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 > ...
3
votes
2answers
86 views

Recursively rename files [duplicate]

there is a whole bunch of files all of them who have the pattern joob_1_1 joob_1_2 joob_2_1 joob_2_5 so it is joob then underscore numeric underscore numeric - these are also the only files in the ...
0
votes
1answer
22 views

how to pass single file not list of files

I am running this command while IFS= read -r file;do split -l 20000 -d "$file" "$file";done < file.list.txt now my problem is that this accepts as input a list of files (file.list) which looks ...
0
votes
1answer
20 views

Execute scripts and Java programs from apache/PHP

I'm trying to allow apache and PHP to execute a script I have written that is located in /usr/local/lib the script in question is called "pathy" has been added to the path in my .profile, and I can ...
0
votes
2answers
5k views

Bash script with execution permissions won't run with dbl click

I have a bash script that has permission to execute, but when I double click it in nautilus it wont execute, instead it opens its text in gedit. In properties it says open with: gedit, and that ...
35
votes
11answers
113k views

How can I create a select menu in a shell script?

I'm creating a simple bash script and I want to create a select menu in it, like this: ./script echo "Choose your option:" 1) Option 1 2) Option 2 3) Option 3 4) Quit And according to ...
-1
votes
0answers
31 views

Convert perl to shell/bash [closed]

I understand C and C++ and new to perl scripting. I must convert the perl script under the following url to shell or bash: ...
2
votes
2answers
78 views

How can I find windows of a specific application and place them into a grid?

I'm trying to write a script to identify all open chrome windows and move them into a grid layout on a large screen I'm not sure how to find out what the best resolutions would be so I was going to ...
19
votes
5answers
6k views

Run a command with the argument from the last command

When running commands, sometimes maybe you need to run a command with the argument from the last command. How can you do this? Of course, excepting the use of the arrow keys and Del keys: ...
1
vote
2answers
53 views

Determinate if a file is already opened

I want to create a bash script to determine if my file is already opened by another user. I have already tried with lsof but it didn't work as i wanted. The files can have different types of ...
1
vote
1answer
16 views

Problem while trying to create an alias

Goodmorning I was trying to create an alias so as to launch matlab easier. I read this post :How to create a permanent "alias"? and I used the commands in this line echo "alias ...
2
votes
2answers
39 views

How to set environment variables separated by dots

I have to set an environment variable separated by dot in my tomcat startup script. For example host.name=localhost I know shell doesn't accept dot separated variables. Is there a work around ? I ...
0
votes
1answer
31 views

How can I move a file to a directory?

I just want to read from the keyboard the file's name and move it to another directory. I have this in my mind : ls read a // the name of the file pwd read b //the name of the directory where I ...
5
votes
1answer
111 views

Working with text files encoded as Windows-1250 and UTF-8

I am switching between Ubuntu and Windows frequently therefore I have some encoding problems with text files. If I save text file in Ubuntu, everything works fine in both systems. But Ubuntu doesn't ...
1
vote
2answers
63 views

Running a command in screen daemon mode

I am trying to run a command in screen mode using the command screen -dmS screen_name sed -i 's/a/b/'g some-file.txt Nothing happens. When I put the same command in a script and run the command: ...
1
vote
2answers
175 views

bash: ./name.exe: Permission denied

I want to execute a program in Ubuntu 12.04...but when I type ./programname.exe it makes error: bash: ./gbat.exe: Permission denied and I typed "chmod +x programname.exe" , but it doesn't fix ...
14
votes
9answers
616 views

How to write a shell script to assign letter grades to numeric ranges?

I want to make a script that would prompt you for a number between 0-100 and then give you the grade based on the number. I'd like it in bash. PS3='Please enter your choice: ' (Something here) do ...
4
votes
2answers
321 views

How to create a rotation animation using shell script?

I looking for a script that creates a rotating animation using character /,-, | and \. If you continuously switch between these characters it would look like its rotating. How to make this?
2
votes
1answer
55 views

Stacking multiple for in commands

I'm operating on large amounts of data, and have a protocol involving several scripts. I launch it separately for each input file, simply swapping filename in text file containing the command. I would ...
14
votes
5answers
5k views

How to debug bash script?

Is there any way to debug bash script without using echo and logging? I'm talking about using breakpoints and stuff like that.
0
votes
0answers
16 views

How to turn ON/OFF screen monitor using shell script and 'xrandr' linux command?

I am trying to turn on and off screen monitor in Ubuntu14.04 using key bindings. I tried following shell script #!/bin/sh output=$(xrandr | grep ' connected ' | awk '{print $1}' | head -1) ...
1
vote
1answer
23 views

scripting a “manual” apt-get install of kept back packages

TL;DR: is there a way to "automatically" install any kept back packages? I know that apt-get dist-upgrade is too blunt of an instrument. Details... I have a bash script that runs (periodically) to ...
2
votes
1answer
63 views

How to make a batch file add users to groups?

I need help with a GCSE project, I'm stuck on the last question. It asks for a bash script to create users, and then assign them to groups. I've already made the script add new users, but I'm unsure ...