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

3
votes
2answers
2k 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 ...
0
votes
0answers
14 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
29 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
-2
votes
2answers
40 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
57 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
39 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
15 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
31 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
20 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 ...
2
votes
0answers
42 views

How to have a video player resume from where I last left off?

I'd like to be able to launch a video player (VLC, SMPlayer) via Terminal, using some command like resume_media and then it will automatically find the most recently played media file (.mkv, mp4 etc.) ...
0
votes
0answers
19 views

How to get a list (from shell) of Icon Themes installed?

I'm developing a simple script for change the icon theme with Unity. How could I know all the current (Ubuntu & Unity) System Icon Themes with a shell command? There are a few folders in ...
0
votes
2answers
41 views

Shell script to copy a specific file from one folder to another with date

I want to write a script which look for a specific file in a specific folder. file name and location will be pre-define in the script. A loop will run, if the file exist, it will copy that file to ...
0
votes
1answer
45 views

Can't run script with proz on Ubuntu

I am trying to compile iOS code on Ubuntu. Trying to set up all tools according to: https://code.google.com/p/ios-toolchain-based-on-clang-for-linux/wiki/HowTo_en I get stuck on the point: ...
1
vote
1answer
61 views

Problem with shell script to reboot computer/switch to windows

I have little experience with linux and hardly ever wrote an shell script, but needed a workstation with both windows and linux to do certain calculations. The workstation is however mostly used ...
0
votes
0answers
30 views

How can i change a script to a system command? [duplicate]

If I have a script, let's say shebang.sh. To execute, I have to do './home/user/Desktop/shebang.sh ' How can I make it 'shebang' From any directory?
0
votes
0answers
16 views

x-shellscript opening with gedit

I've downlodaded this plymouth theme, but when I try running the install-orb script, it opens in gedit I already checked "Allow executing file as program" in properties, but it won't solve. @edit ...
0
votes
1answer
35 views

How to run a script on a remote computer from a local computer over ssh and save the ouput on the local computer to analyze further?

Lets say i have a script in my local computer like the below one which will list files of a directory on my remote computer and run a "for" loop to save the files on my local computer. Then a check ...
1
vote
1answer
21 views

How a Script exit when a software does not install properly?

i got idea form the link (How do I write an application install shell script?) and started to wrtie script for installing software in ubunt automatically. But in case if the software does not install ...
6
votes
1answer
111 views

Executing a script when inserting a flash drive

How can I write a script that fires on an event? When I insert an USB flash drive, Ubuntu mounts it and automatically opens Nautilus. When this happens with a specific flash drive, I'd like to open a ...
0
votes
0answers
17 views

How to batch download youtube-dl trailer based on a folder name?

I have some folders with movies and I am trying to figure out how to download trailers from youtube Folder structure: |-Movie Name #1 (2008) |-Movie Name #2 (2013) |-..... Trailer file: ...
0
votes
1answer
31 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 ...
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 ...
2
votes
1answer
81 views

Shell script for list of users by groups

I want to write a shell script that generates a list of users. for each user display the username and ID and all groups the user is a member of it means like GROUPS command but for all users and with ...
3
votes
4answers
250 views

How to select and print IP address from a set of strings?

I have a sentence whic contains an IP address. For example, This sentence contains an ip number 1.2.3.4 and port number 50, i want to print the IP address only. From the above sentence, I want to ...
0
votes
1answer
18 views

Where can I find a good tutorial to take me through the baby steps of shell scripting? [closed]

I am an extremely poor programmer who has got to do this. I need a really basic tutorial that builds me up to being able to write shell scripts but have found that not everything I stumble upon is ...
1
vote
3answers
95 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?
2
votes
3answers
49 views

create a .tar file of all latest files in the directories

I am in a directory A. This has a lot of sub directories B, C, D. Each sub directories will have a list of files. I need to create a .tar file of all the latest file in each subdirectory. Example: ...
1
vote
1answer
27 views

How to retain back to the last permission of file or directory

I have accidentally changed the permission of a file now I want that file to back to the last permission state but how to do this? Is there any procedure or tool or any command line script which keep ...
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 ...
0
votes
1answer
21 views

Can an sh (or index file) be used in CCC profiles instead of the binary?

I am trying to set custom graphical options in AMD Catalyst Control Center for a specific program. There is a single sh file that launches it but there are 4 completely different binaries (not ...
1
vote
2answers
112 views

Shell script file (.sh) does not run, and throws an error

I am new to linux, and I have a shell script (.sh) file I on my Desktop that I want to run. These are the steps that I did: This is the content of the test.sh file on my Desktop: #!bin/bash ...
1
vote
1answer
76 views

ffmpeg-video trim from the end of the video

I have some videos of different duration.I want to cut(remove) the last 5 seconds of all videos.Can i use 'ffmpeg' in a loop to trim the videos?please help me.
-1
votes
1answer
53 views

Copying 100 files at a time using terminal [duplicate]

Is there an option to copy first 100 files from a directory to another location using the cp command? If not is there any other way to do this? Do i need to write a script?
0
votes
0answers
14 views

Count total no of functions in .h files

I want to have a count of total exposed functions in my module? I tried grep -rn "(" *.h|wc -l but I am not getting exact answer How do I count total number of global functions in my module?
0
votes
0answers
17 views

Dual booting thwarted by rogue keyboard presses?

End goal: successfully dual boot Windows 8.1 and Ubuntu 14.04, both are already installed and working. I just can't get to the bootloader (I think it's called) to choose to go back to my Windows ...
1
vote
0answers
35 views

Unable to connect to X11 display. is $DISPLAY set? - Yes, it is

I'm trying to run this in my /etc/init.d/rc.local. I had to manually add the exit 0 because it wasn't there by default if that makes any difference. cd /home/john/xcape && ./xcape -e ...
0
votes
2answers
49 views

if stament in shell script

How write in if [ -z $str1 && -z $str2 ], "&&" doesn't work, if write [ -z $str1 ] this is work. I want to once two string #!/bin/bash echo "Enter first string" read str1 echo ...
3
votes
2answers
146 views

For loop syntax bash script

Is there a way we can implement some thing like this in bash script ? pureips="10.3.1.111 10.3.1.112 10.3.1.114"; pureservers="a b c"; for ip,server in $pureips,$pureservers; do echo "$server | ...
1
vote
2answers
9k views

Shell Script Desktop Shortcut

So I tried making a desktop shortcut which executes a very simple shell script. But when i double click/right click->execute it, it does nothing. (or at least I think it does nothing) heres how my ...
2
votes
6answers
1k views

How to command grep not to display the searched string? [duplicate]

I want to print a part of a line in a file. The whole line looks like this. Path=fy2tbaj8.default-1404984419419 I want to print only the characters after Path=. I have tried grep Path filename | ...
7
votes
5answers
743 views

How to send a file as an input to another file?

Through the command shell we can redirect the three standard filestreams so that we can get input from either a file or another command instead of from our keyboard, and we can write output and errors ...
8
votes
2answers
21k 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 ...
0
votes
1answer
123 views

curl .gz file and pipe it for decompression

I am trying to download some .gz files (N.B. not .tar.gz ones) from given URLs and decompress them to overwrite existing files, if any. For each individual download, I tried the following: curl -O ...
0
votes
2answers
67 views

Copy a word from the html file of a web page using shell script

I am trying to write a shell script which should crawl into a web page and fetch a particular character/phrase from its html and display it. Particular character means, for example if the html of the ...
0
votes
0answers
37 views

Shell script to check url

I am trying to write a shell script to check for the existence of a particular directory in a particular domain name. For example, I have a web site named www.example.com. I want to check whether the ...
1
vote
2answers
30 views

Why sudo could not get the right PATH environment?

I run command sudo hadoop fs -ls /, it said hadoop command is not found. But I have already set it in /etc/profile, and also I verify it by switch to user root. What happens here ?
1
vote
1answer
45 views

Fire command on client system from server

I have two ubuntu systems one server and another is client. So I have written one script on server, following are the code of script file: Code for login into the client system `sshpass -p ...
1
vote
1answer
48 views

How to create your own commands that can be used anywhere [duplicate]

I am new to linux, and I am learning bash scripting at the moment. I was wondering how I would save my script as a command and then be able to call that command anywhere in the terminal. So i could ...
11
votes
5answers
7k 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 ...
9
votes
2answers
1k views

What does the first '.' mean in '. ~/.bashrc'? [duplicate]

I saw a post about fix your alias in .bashrc. And he says after you put your alias in .bashrc , you need to use: . ~/.bashrc I do not quite understand what the first dot(' . ') does here. What's ...