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
13 views

What is a (reasonably) secure and automated way to backup my mysql database using (any) free cloud/online services?

I have a mysql database that I use for personal devlopment. I would like to back-it up online using any free (in cost) online storage. (dropbox, google-drive etc...) I am assuming a shell script ...
1
vote
1answer
17 views

Creating custom text expansion for password template

Let me explain. As a security measure, my current password system is a complicated combination of letters and symbols, to ensure a different password is used for each website I use a base password as ...
2
votes
4answers
58 views

Remove whitespace from all array elements

I have a array called arrayvar, which is being defined as arrayvar=( $(awk '/'"$vovar"'/,/}/ {gsub("'"$vovar"'"," "); gsub("}"," "); gsub("{"," ");gsub(","," ");print}' temp1 | tr -d '\n' | sed ...
2
votes
5answers
66 views

Add particular strings to an array sed/awk/grep

I have this ciscoFlashCopyStatus OBJECT-TYPE SYNTAX INTEGER { copyOperationPending(0), copyInProgress(1), ...
2
votes
3answers
87 views

Give files user permissions

I'm having a hard time solving this problem. write a shell script to check the executable rights for all the files in the current directory. if the file doesn't have the user executable right then ...
0
votes
0answers
18 views

Any problem launching script with infinite loop using cron?

If I run a shell script containing an infinite loop using cron @reboot, will that hang up the cron daemon or does cron keep moving and not wait for the job to terminate?
0
votes
2answers
65 views

Shell script options with parsing arguments

I have the shell script CONTROLLER_IP="" if [ "$#" -eq 1 ] then CONTROLLER_IP=$1 else echo "Usage : create_endpoint.sh --controller-ip <Controller IP>" exit 1 fi but its executing ...
2
votes
1answer
63 views

Conditional file and directory installation in `.deb` Packages

Is it possible to create a binary .deb package with conditional files and directories installation (e.g. installation of an init script in /etc/init.d/ after being confirmed by the user)?
0
votes
0answers
9 views

Start Rails Application on Boot Ubuntu

I am trying to make my application Ruby on Rails (OpenProject) starting with the system boot, but to test the script as root, returns me the error: /usr/bin/env:ruby: No such file or directory. My ...
3
votes
1answer
94 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.) ...
2
votes
1answer
382 views

How to remove element from gsettings array in script?

Array in dbus/gsettings has a format [element1, element2, element3, ...]. Gsettings' interface allows only replacing existing array with another, so for instance, adding another item element can be ...
7
votes
2answers
135 views

Harmless pranks there for the command line? [closed]

Seeking harmless pranks or April fools for Ubuntu (one-liners), with which I can bring my colleagues laugh. However, it should not damage the system. To broad, ok… Only shell scripts With a maximum ...
16
votes
1answer
2k 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
1answer
37 views

Cannnot run a .sh file in terminator [on hold]

I am having trouble running a .sh script file in Terminator, however I can run it perfectly fine in the default terminal Ubuntu comes with(gnome-terminal). This is what I get when trying to run it in ...
-7
votes
1answer
46 views

How to create and exploit a zip bomb? [on hold]

I am trying to create a zip bomb using shell. In one of the previous answers on the site, I saw this: dd if=/dev/zero bs=1000 count=1000000 | gzip > test.gz How does the above command work ? I ...
2
votes
1answer
25 views

Passing Variable into awk gsub

I have this command Here vovar=OBJECTS prvar="$(awk '/'"$vovar"'/,/}/ {gsub("$vovar"," "); gsub("}",": %s,"); gsub("{"," ");gsub(",",": %s,");print}' temp1)" Contents of temp1 ...
-2
votes
0answers
17 views

How will my users get public ip from my private server? [closed]

I have a private server and I want my user to get public IP via bridge. My IP range is 172.16.0.1-50. I am running CentOS on the server.
0
votes
1answer
25 views

Try to execute a script (adduser.sh) in root /$

I'm a new user to Linux and been practicing using creating/using scripts in bash. I found a script to add new users automatically but when I try to run the script in root, I keep getting the same ...
1
vote
2answers
34 views

Make echo ignore spaces?

I have a file called temp1 sCellEventTrap-03-27 TRAP-TYPE -- CAC Code: 01 ENTERPRISE compaq VARIABLES { scellNameDateTime, scellSWComponent, ...
0
votes
0answers
13 views

OpenVPN --up called scrip does not work properly

I use such command to run my OpenVPN connection (part of script): gw=`netstat -rn|grep UG|awk '{print $2}'` openvpn --config ./openvpn.ovpn --up "./up $gw" >/dev/null 2>/dev/null& So I ...
1
vote
6answers
75 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
1answer
34 views

create sum, avg and min of file

I have this homework question: create function agg, first argument is filename, second will be sum, avg or min. script will compute sum, average or minimum (dependig on 2. argument) from the ...
1
vote
2answers
102 views

Looping tr command to remove '\r' in multiple files in a directory

I have about 260 files in a directory. How can I input these files one by one into some thing like this file is an array name file=input stream of multiple files x=0 LOOP tr -d '\r' file2 rm ...
0
votes
1answer
23 views

If condition fail skip to end of file

for (( v=0; v<t ; v++ )) do awk '/TRAP-TYPE/{i++}i' $fname >tron if [ "$?" -eq 0 ] then echo "MIB file found" else t=$t-1 fi some other commands echo "MIB not ...
5
votes
5answers
281 views

Compare 2 numerals and copy only similar part sed/grep/awk

Supposing I have a array called a. There are 2 entries in a array a[1] and a[2].So each element contains a numeral value. Both these values have a similar starting numbers however they have different ...
0
votes
1answer
31 views

finding number of array from user input

echo -n "Which station or stations you want to download?" read station ELEMENTS=${#station[@]} for (( i=0;i<$ELEMENTS;i++)); do echo you chose ${station[${i}]} stations to download data done ...
-2
votes
4answers
59 views

Copy a string occurring before a particular pattern.

I am to copy this emuEventTrapInformative from below. -- Traps emuEventTrapInformative TRAP-TYPE ENTERPRISE compaq VARIABLES { scellNameDateTime, shelfId, ...
-2
votes
4answers
134 views

Read number of lines containing a particular string

I have this file: adaptec.mib,sCSISmart1,.1.3.6.1.4.1.795.2.5.0.101,CRITICAL, adaptec.mib,sCSISmart2,.1.3.6.1.4.1.795.2.5.0.102,INFORMATIONAL, ...
42
votes
4answers
2k views

When to use () vs. {} in bash?

I'm studying shell scripting with bash and I need to know the difference between (...) and {...}. How does one select between the two when writing a script?
-1
votes
2answers
114 views

Copying some parts of file

I am to copy "SNMP Agent is up" and "::=101" and count the number of variables present (example here there are 5) and put them in 3 Different variables. FROM FILE.TXT sCSISmart1 TRAP-TYPE ...
0
votes
3answers
78 views

Comparing two strings together

I have array called sev[w] where w ranges from 1 to 21. the array contains the following: CRITICAL INFORMATIONAL CRITICAL INFORMATIONAL INFORMATIONAL INFORMATIONAL CRITICAL CRITICAL ...
1
vote
2answers
2k views

script to compress multiple files

I have a script that generates backup and finds files older than 30 days and compresses them. Now the problem I'm facing is if the files are more than one than how can I edit the script so that it ...
2
votes
5answers
108 views

Condition that matches all occurrences of a word in a file ad does something

I am to do something like this for (( every occurrence of the word TRAP-TYPE in a file )) do desc="$(< inputfile awk '/DESCRIPTION/ {getline; gsub(/^\s*"/, ""); gsub(/"\s*$/, ""); print}')" ...
3
votes
5answers
202 views

sed remove last 2 numerals

I have the following. oid=.1.3.6.1.4.1.795.2.5.0.xxx (these 0.xxx represent any random numeral) I want to do the following echo $oid | sed (some commands to remove 0.xxx) and store the resulting ...
0
votes
1answer
33 views

2 Dimensional array Error in shell

#!/bin/bash i=$(awk '{x++} END {print x}' mibwithtraps) echo $i IFS="," while read f1 f2 f3 f4 do echo "hell :$f4" done < mibwithtraps This prints this: 7 hell :CRITICAL, hell ...
1
vote
2answers
29 views

New to script question: 'else' not expected in BASH script

Could someone help if possible. I am trying to resolve an issue I have in this script. I am getting 'else' not expected, but the logic seems to make sense. Scripting is all new to me, but I am ...
1
vote
2answers
46 views

Copy particular text from one file to other using GREP or SED

I am to copy the number 795, and use it another file. This 795 could be any number and can change from file to file. Everything till the enterprises will remain the same even the ending curly ...
0
votes
1answer
25 views

I am getting this error message in the terminal and cannot run / execute shell script on my PC. Why?

I was trying to execute the android.sh file in the terminal from my desktop; I got the following errors in my terminal: $ sudo chmod +x ~/Desktop/android-sdk-linux/tools/android.sh [sudo] password ...
2
votes
2answers
24 views

Checking a floating point value within a range

Just wondering how can I check if a floating point value is within a certain range using "bc" and the conditional statements in bash. Thanks in advance For example,I want to find out if 17.2 is ...
-1
votes
4answers
46 views

=0 command not found bash

grep "::=BEGIN" -q < /home/erawson/bin/HP/adaptec.mib CHK= echo $? if ($CHK = "0") ; then echo "failed" else exit fi error is: /home/erawson/bin/try1: line 10: =: command not found
3
votes
4answers
249 views

how to change file extensions in a directory [closed]

I have many files in a directory having extension. .text(2) .text(1) I want to remove the numbers from extension and output should be like .text .text Can anyone please help me with the shell ...
1
vote
2answers
42 views

Generating 2D array in Bash with unknown dimension

just wondering if it's possible to generate a 2D array if the dimension is not known prior to user input. For example if user input 2 2 on the commandline the shell will generate a 2D array base on ...
3
votes
1answer
43 views

Part of shell script not getting executed

I have just started taking baby steps into shell scripting. My script goes something like this: firefox -new-tab -url google.com -new-tab -url yahoo.com clear cd /opt/lampp sudo ./lampp start cat ...
4
votes
3answers
81 views

Getting internet browsing history from shell

is it possible to use the shell or generate a shell script to find out the browsing history from the browsers installed on the system? thank you
18
votes
4answers
38k views

How to run a script during boot as root

I had a script that automatically enables my wifi without using networkmanager, but I don't know how to run the script as root while the system is booting. How do I make the script run automatically ...
1
vote
3answers
75 views

Bash shell for loop process with two paired variable names

It's common to use bash shell for example to bulk rename plenty files. Usually I used the following structure, for file in ./*.short do # do command done That's for filename with .short extension. ...
2
votes
1answer
87 views

Find and Rename recursively in folders, subfolders and multiple files

I'm new with shellscript and I'm having some problems trying to do what I need... I want to 'optimize' all my *.png images and found this so I made the bash as it says with: #!/bin/bash pngnq ...
0
votes
0answers
18 views

Run sequence of commands and ssh password

I want to create a script that allows me to run ssh, input the required password, and then execute another command on the ssh console. Is there a way to do that? For example, this is what I would ...
4
votes
2answers
201 views

Move files to directories depending on their extension [duplicate]

I have a directory with huge number of files with different extensions. What I want to do is to move each extension to a folder with name the extension itself, and those files without extension move ...
0
votes
0answers
12 views

Remote child process doesn't end

file test.sh contains below lines. !#/bin/bash while [ "1" ] do date done This file resides inside machine 10.1.1.3. I want to execute this script from a remote machine 10.1.1.2. Let say from ...