In shell scripting, a shell such as bash runs a file containing a list of commands (a script). The script is effectively a program and the shell is its interpreter.

learn more… | top users | synonyms

1
vote
1answer
43 views

How do i write a terminal script to setup ubuntu for me instead of spending days every time?

From what I understand I can make a text file with all commands same as I would type in terminal, make it executable and run it. Would running sudo mysetup.sh or mysetup.txt be OK so not typing PW ...
0
votes
3answers
483 views

How to write a script to “listen” to battery status and alert me when it's above 60% or below 40%?

I want to make a tool that alerts when battery is below 40% or above 60% so I can start/stop charging accordingly. I know some tools alert when battery is low, that's not enough. Is there a tool that ...
1
vote
2answers
27 views

convert with bash - trim/crop and center

i need a fast and reliable way to modify a lot of images. There is a lot of white around my pictures i want to get rid about. The problem is, it is a number of similar pictures, but they have ...
2
votes
1answer
49 views

Can there be two init processes?

I am new to Operating Systems (specifically Linux) and this is my first question here I want to ask, can there be two process with CMD = init (as given by ps - e command). I had two processes on my ...
13
votes
1answer
1k views

How to display random jokes from www.icndb.com in your terminal?

I already know that you can get some nice quotes/jokes using the fortune program. But I've found in this urwird script a new source of fun that I'd like to have when I open a new terminal. This time ...
0
votes
3answers
42 views

Shortcut to execute shell scipt? [duplicate]

I'm trying to create a shortcut that will run a .sh file deep in some directory without having to navigating to the absolute path. I have tried using aliases, which did not work as. Using soft/hard ...
0
votes
0answers
25 views

Reconnecting network through shell script

I've written following code to reconnect to network: #!/bin/bash while [ "$var" != "end" ] do pingtime= $(ping -w 1 192.168.1.107 | grep ttl) if [ "$pingtime" = "" ] then $(sudo ifconfig ...
3
votes
2answers
893 views

What is the difference in running script with ./

What is the difference between running the script by calling directly its name and calling the script by adding a with prefix of './' . I can't find any difference in run time.
1
vote
1answer
52 views

Bash script to remove item from Nginx cache

I have Nginx running in Ubuntu. I'm trying to write a script that deletes an item from the Nginx cache. Script: clear_single_cache_object.sh #!/bin/bash echo "Deleting: " $1 grep -lr $1 ...
9
votes
2answers
3k views

Anyway to make hotkey to turn screen off?

I was just wondering how can one make a script (or make some changes) by which I can turn screen off in Ubuntu(12.04) whenever I want, the way screen can be turned off in Cellphones. And also I would ...
9
votes
2answers
117 views

Run only parts of a script as sudo, entering password only once

I am writing a script (actually a combination of scripts and makefile) that installs external dependencies: some apt-get commands, some git cloning, building, installing, adding users to groups, ... ...
1
vote
1answer
33 views

Set up shortcut for different terminal shells

I would like to get some practice using different shells (zsh and ksh, etc...) What is the best way to set it up so I can create a shortcut that will launch a terminal with the desired shell? I'd ...
10
votes
3answers
771 views

How to do: underline, bold, italic, strikethrough, color, background, and size in Gnome Terminal?

How to do: underline, bold, italic, strikethrough, and color in Gnome Terminal? Bold Italic u̲n̲d̲e̲r̲l̲i̲n̲e̲ s̶t̶r̶i̶k̶e̶ ̶i̶t̶ ̶l̶i̶k̶̶e̶ ̶i̶t̶s̶ ̶h̶o̶t Color background font < (its mono ...
0
votes
2answers
35 views

Whitespace Problems With Script and Variables

I'm trying to beat my head against the syntax of this. I'm getting problems with whitespaces and I can't see if there's a better way to do this. vardir=/home/user cd $vardir for i in $(ls "$vardir") ...
11
votes
3answers
23k views

How do I run 'sudo' command inside a script?

To do a patch manually I must type this command sudo ./playback_delete_data_patch.sh 09_delete_old_data_p.sql There is a space just before the 09: sudo ./playback_delete_data_patch.sh [space] ...
6
votes
3answers
1k views

Difference between ls -l and ll?

I'm relatively new to programming as a whole and some tutorials have been telling me to use ls -l to look at files in a directory and others have been saying ll. I know that ls is a short list, but is ...
0
votes
2answers
57 views

Export $DISPLAY value in Shell script

I am trying to Print the value of $DISPLAY under my Shell script. I have Following shell script which Exports the DISPLAY: #!/bin/sh export DIPLAY=:10.0 Here, each time I need to change the Value ...
0
votes
1answer
36 views

How to check if a variable is empty on command line? [duplicate]

I have the following shell script echo "please enter user name: " read USER_NAME while [ ! "$USER_NAME" ] do echo "User name can't be empty please re-enter: " read USER_NAME done How can I do the ...
0
votes
0answers
37 views

How to change another user keyboard layout silently?

I'm working to automate development environments with Vagrant which manages Ubuntu Desktop 14.04 VMs. My Vagrant script: Creates the VM Setup a new user account based on the host user account Does ...
0
votes
1answer
31 views

Things That Can Be Made In Shell Script? [closed]

So I just started using shell scripting, and was wondering what type of programs you can create. I want to continue using shell script, but if it doesn't lead to anywhere particularly useful I ...
0
votes
2answers
45 views

How do you create a shell script?

I need to create a shell script that will create a user then put it into a group. How do I do it?
1
vote
1answer
15 views

package “state” vs “selection state”

All answers that I read, suggest listing/saving package selection states. i.e. dpkg --get-selections But the selection state could be different from actual. So why use that? Is it just because ...
-1
votes
1answer
31 views

Do something in terminal that involve changing user [closed]

I want do something in terminal that involve changing user like: sudo su do something do something exit do something do something sudo su do something do something exit I've tried to do something ...
10
votes
2answers
224 views

Auto clear search term from lens

There must be a setting or a shell script that would clear the terms from the lens every time it's closed. The behaviour would be: open lens and type a term. reopen the lens with super key. see ...
1
vote
1answer
35 views

My script only opens new terminals when the previous command's terminal is closed

Sorry if my title is a little hard to understand, I tried to condense the issue as much as possible. I'm trying to run a bash script which opens a new terminal for each major command, that way I can ...
1
vote
1answer
82 views

While Loop Syntax Error

I'm attempting a modification of apt-fast to support parallel downloading and installation. I'm having some trouble with this loop: get_install(){ while ((!${pkg}-finished)) do if [ "$CURNUM" -lt ...
0
votes
0answers
34 views

Script to install software after clean install

I apologize for opening a new thread on this, as I am simply asking for a bit more info on this post Creating a script to install software after a clean install? -- but I don't have enough reputation ...
3
votes
1answer
134 views

How to display all services and version that runs on a host?

I am trying to display all services and their versions that runs on a host using ports from 1 to 1023, in this way: ssh, OpenSSH 5.9p1 Debian 5ubuntu1 (protocol 2.0) smtp, Postfix smtpd http, Apache ...
0
votes
2answers
108 views

How to read user last email using a shell script?

Let's say I have two machines A and B On A I have installed and configured a SMTP and IMAP server For example I have user: george with password: 123456 on Machine A I am trying to write a shell ...
2
votes
3answers
44 views

How can I refer to all files that are named using two numbers?

I want to make a shell script that downloads all files that area named [0-9][0-9].png; e.g: 00.png 01.png 33.png 91.png etc files = ??????? for file in files do curl ftp://server/${file} done ...
1
vote
1answer
43 views

Get results from PHP pages after login [closed]

I have 10 php files like 0.php , 1.php, 2.php etc All those files contains an auth form which send two inputs username and password to itself via post. After login there is a message displayed. I ...
3
votes
4answers
551 views

Is it possible to create commands, put it in one file and run without “./”? [duplicate]

If I create a script in a file like this: #!/bin/bash echo "test" As far I know (as a newbie) is to put it in some folder then make it executable with chmod +x myscript and then execute it with ...
0
votes
0answers
18 views

ftp in script is asking password though the password is in script

Previously the below script have not asked password when execute but all of a sudden it is asking password. I have tried to pass the username, password and server name in single quotes but still it is ...
10
votes
2answers
27k views

How to read complete line in 'for' loop with spaces

I am trying to run a for loop for file and I want to display whole line. But instead its displaying last word only. I want the complete line. for j in `cat ./file_wget_med` do echo $j done result ...
-2
votes
1answer
34 views

How does this lowercase expression works in bash

I want to convert a vaiable value to lower case. To do this, I am doing following lower_case_var=echo ${var,,} Above expression works fine. However, I am wondering that how it works?
17
votes
6answers
38k views

Not able to execute a .sh file: /bin/bash^M: bad interpreter

I wanted to execute a shell script: -rwxr-x--x 1 root root 17234 Jun 6 18:31 create_mgw_3shelf_6xIPNI1P.sh I tried to do a standard procedure, but I am got this error: ...
1
vote
3answers
71 views

creating a command to load a shell script from command line

Right now when I want to run a specific program, I perform the following task: cd ~/Downloads ~/Downloads$ cd RubyMine-6.3.3 ~/Downloads/RubyMine-6.3.3$ cd bin ./rubymine.sh Instead of doing all ...
-2
votes
1answer
129 views

How to make a shell script pipe aware

I have the following script: #!/bin/sh [ "${#}" -eq "0" ] && (printf "%s\\n" "${0}: word ..." >&2; exit 1) _whats() { [ -z "${1}" ] && return 1 [ -z "${2}" ] ...
2
votes
4answers
555 views

Why is this Bash script not working?

I wrote a small Bash script so that the image in the folder becomes the wallpaper: for f in *.jpg do gsettings set org.gnome.desktop.background picture-uri file:$f The error is: ./wall.sh: ...
0
votes
2answers
435 views

dconf change a string key

I'm trying to change a string based dconf key with a bash script, using the following command line: dconf write /org/gnome/nautilus/preferences/show-directory-item-counts 'never' But it return the ...
0
votes
1answer
27 views

Short keys to make a line comment in shell script Emacs?

I want to write shell scripts by using Emacs. I have already known to turn shell-script-mode on, but still don't know which short keys to make a line become comment. For example, which short keys in ...
0
votes
2answers
44 views

Bash: Regular Expressions in substitution

I have a bash script to substitute number values inside a text pattern. Suppose I have a file like this: word5word word55word And I want it to look like this: word125word word125word I have this ...
0
votes
0answers
22 views

How to identify with desktop environment id installed to configure lightdm-theme

I have a creepy problem here. I have to identify the desktop environment installed by an user without to know with one it's used by an user to change the user session value ion some lightdm-files. ...
1
vote
3answers
43 views

How to get up time for the terminal

How to get the uptime from. The terminal. And in a bash file but only the uptime no other infomAtion I would like it to be on one line
-4
votes
2answers
81 views

Search csv file column

Is there a way to search the content of a specific column of a csv file using the terminal. But that it still returns all the information of the rest of the columns. I want to be able to search for a ...
-1
votes
2answers
60 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 can I fix this? for file in $1/*; do echo `stat ...
1
vote
1answer
80 views

Is there a way to reprogram the thinkvantage button to assign a shell bash program to it?

Is there a way to reprogram the lenovo think vantage button to open and run a shell bash program on ubuntu 14.04 lts? I have tried system preferences > keyboard >shortcuts > custom and assigned a ...
0
votes
0answers
18 views

display number of packets

need to write a script that takes and interface as parameter and prints to stdout like this: interface TX: no.of tx packs sent RX: no of rx packs sent this is what i have written, but it prints the ...
2
votes
3answers
37 views

Script not having permission to write

Hello i have to write a script with the name setip that can be ran like this: ./setip ip mask ,and that must set the ip ip and the mask mask on the lo1 interface.this is the content of my script, but ...
0
votes
0answers
31 views

Simple Mount Script Not Working?

just really not understanding what's wrong here. I had a script that worked fine on 14.04, but I screwed up something on there and accidentally removed some system apps and made it fail to boot. So, I ...