A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.

learn more… | top users | synonyms (2)

2
votes
0answers
52 views

Bash completion extra space when adding file directory

I have a script for extending bash-completion for certain commands. If I type command1 and do a tab, it should auto-complete with a file directory (and the files). It works fine expect for one ...
1
vote
1answer
60 views

KSH script having trouble reading in variables line by line

For starters, I'm not the most advanced scripter. I was asked to create a script that would search through a directory for print files older than 14 days and move them to an archive directory. There ...
0
votes
4answers
61 views

Find folders that begin with the same string

I have more than 1000 subdirectories in a folder. Some of them begin with the same string and I want to find all directories where the first 5 characters of their name are also the first 5 of another ...
25
votes
6answers
46k views

File extensions for unix shell scripts

On wikipedia, the article for .sh says: For the .sh file extension type, see Bourne shell. How about other unix shells? I know that the shebang is used inside the file to indicate an ...
1
vote
0answers
38 views

ImageMagick + ruTorrent-stats (Github repo)

I am trying to combine information I found here on the Unix & Linux Stack with I Wim Leers' rutorrent-stats I have some experience with coding simple websites and while I am by no means a ...
-1
votes
0answers
13 views

triggering file transfer with a criteria for time and validity of file with the specific words

i want monitor directoryX/folderA for new files and trigger a copy of all those files that have a specific list of words/ headers in the first line of my file to a different directoryY/folderB . And ...
0
votes
0answers
55 views

service doesn't work

Background I am using this script in order to make my script running as service. I am using Linux Mint 17.3 Rosa. The problem Sometimes the start/stop works sometimes not. Sometimes, I have to ...
8
votes
5answers
6k views

Intersection of two arrays in BASH

I have two arrays like this: A=(vol-175a3b54 vol-382c477b vol-8c027acf vol-93d6fed0 vol-71600106 vol-79f7970e vol-e3d6a894 vol-d9d6a8ae vol-8dbbc2fa vol-98c2bbef vol-ae7ed9e3 vol-5540e618 vol-...
0
votes
0answers
20 views

find lastly zipped file in a directory which has so many zip files [duplicate]

I am trying to make a script in that i need to execute a command which can give me the lastly zipped logfile(ex:my log file is going to be zipped toady so i need to place this file in script.likewise ...
9
votes
5answers
9k views

Check if script is started by cron, rather than invoked manually

Is there any variable that cron set when it's running a program ? If the script is running by cron, I'll skip some parts; otherwise invoke those parts. How can I know if the bash script is started by ...
0
votes
1answer
45 views

How to grouped the following variable and command and read 1 by 1

I've following array and variable : httpurl="http://www.nnin.com" firstquery=$(curl -s -X POST -d "UID=user1&PWD=1111" $httpurl) name="firstcust" ip="105.105.0.1" httpurl="http://www.mmim.com" ...
1
vote
2answers
22 views

Merge PDF document but with conditions

I make bus timetable booklets for drivers every day, and I have 4 PDF files: Special Instruction Sheet (Every day different) Bus daily timetable (which is always different) Bus Assistant daily ...
23
votes
4answers
101k views

how can I add (subtract, etc.) two numbers with bash?

I can read the numbers and operation in with: echo "First number please" read num1 echo "Second number please" read num2 echo "Operation?" read op but then all my attempts to add the numbers fail: ...
2
votes
1answer
1k views

How to create gcov files for a project in a different dir?

I want to analyze code coverage datas. I want to create gcov files from OpenSSL (and from other projects), but I can only create them in the same directory of the project, and only for the files in ...
0
votes
1answer
27 views

update lines in a file

I have a file,where it has some fields.For example, var One = "fcb"; var Two = "abc"; How can I update/replace these lines using a script? I want to be able to do something like : echo -n "...
0
votes
2answers
47 views

SFTP to upload files at cronjob

I want to use SFTP to upload files from A to B. path for A: /tmp/A path for B: /tmp/B server B has own username & password. my cronjob will run every 10 mins to check whether there are new files ...
17
votes
10answers
69k views

Automatically run commands over SSH on many servers

There is a list of IP addresses in a .txt file, ex.: 1.1.1.1 2.2.2.2 3.3.3.3 Behind every IP address there is a server, and on every server there is an sshd running on port 22. Not every server is ...
0
votes
4answers
68 views

How can I run a command periodically and indefinitely till it's turned off?

I want to run a command every several minutes until I turn it off. After some searching, I found lots of ways of doing the first half (running a command periodically and indefinitely), what about I ...
0
votes
2answers
231 views

How to update three CSV files based on a fourth file

I have four csv files, and I want to update a set of three, based on the values in the fourth file. file_1 contains names. file_2 their numerical ids. file_3 contains ids from file_1 and file_2, ...
0
votes
1answer
515 views

Is there a way of copying only directories and not files? [closed]

I want to copy only directories from a folder on a remote server to my server. Is that possible? Here is the code I have so far but it copies files and folders: scp -rq username@192.168.78.331:/copy/...
2
votes
2answers
328 views

Run a ping command on list of servers and output to a file

I have a file servers.txt on a different server, with list of servers: server1.mydomain.com server2.mydomain.com server3.mydomain.com I want to first download this txt file, ping these servers and ...
2
votes
2answers
3k views

LVM2: Obtaining lv and vg names from path (volume group name and logical volume name)

Let's assume we have lv path: lvpath=/dev/mapper/vg2-Music Than I split lvdisplay -c with cut: vgname="$(lvdisplay -c "$lvpath" | cut -d ':' -f 2 )" lvname="$(basename "$(lvdisplay -c "$lvpath" | ...
3
votes
1answer
71 views

tmux script to launch several commands

How can I write the following in a bash script? tmux # Start tmux session. compass watch /path/to/project1/compass/ # Run the first process. Ctrl + B, " # Split the pane. compass watch /path/to/...
-1
votes
0answers
16 views

How to run a function for a specific received packet? [duplicate]

I am doing an experiment for my master thesis. I want to run a function (e.g. multiply two numbers) when a specific packet is received (e.g. a packet with destination TCP port 6666). For example, I ...
0
votes
2answers
66 views

How to add users from data in a text file

I am a beginner in linux. I have a question about creating multiple users in linux, but I need a program to work on it. There is a new users txt file, the content is following: adams:5000:Adams, John ...
1
vote
1answer
3k views

How to execute Netscaler commands through a remote machine via SSH connection

I have been trying to execute some NetScaler commands like "bind" & "unbind" through a Linux Box via an SSH Connection. Now the Problem is, Manually we are able to enter & execute commands on ...
0
votes
2answers
31 views

Passing variables to script [duplicate]

What is the difference between: ./script.sh "$VARIABLE" and ./script.sh ${VARIABLE} Is there any?
20
votes
4answers
59k views

Confusing use of && and || operators

I was skimming through an /etc/rc.d/init.d/sendmail file (I know this is hardly ever used, but I'm studying for an exam), and I've become a bit confused about the && and the || operators. I'...
3
votes
2answers
69 views

Can you tell if a file has been renamed?

Many tools out there for syncing files aren't quite right for syncing you're home directory. Because of this, and to learn Ruby, I've been working on my own sync tool. An issue I've encountered, ...
0
votes
0answers
4k views

How to execute grep in tcl for getting XYZ-123 type pattern

How can I execute this grep command in TCL? grep '[A-Z][A-Z][A-Z]\-[0-9][0-9][0-9]' file1 > file2
0
votes
2answers
41 views

cat doesn't join my files when I run inside script

I'm doing a restore backups script, and when I try to join files which are splitted, cat prints that error: cat: fullbackup_mrbsNuevo_15_6_2016.tar.gz.*: No such file or directory The line that ...
1
vote
1answer
49 views

How to compress all files in folder and erase the untared versions via command line?

I have a backup disk containing uncompressed versions of my files that I would like to compress to save space on this disk. The disk (containing files to compress) is full (about 3TB with 17GB free). ...
0
votes
1answer
471 views

Echo semicolon in bash

I am trying to write to a file the following string: 1;2;3;4. The semicolons create problems. I have been able to figure out the following ecamotage to do it: variable='1;2;3;4' echo "${variable//;/\...
1
vote
1answer
521 views

Why is my loop not continuing properly in my rock paper scissors game?

I'm making a bo3 rock paper scissors game. So far I've gotten it to work under every condition except ties. When a tie happens, it's meant to 'remake' that game by just subtracting 1 from I. It doesn'...
0
votes
0answers
27 views

Why is this udev remove rule not working? [duplicate]

Hate to ask this sort of question, but... Device info: udevadm monitor --env UDEV [3048.530438] remove /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6.3 (usb) ACTION=remove BUSNUM=002 ...
0
votes
1answer
411 views

What's wrong with my elif statements in this rock paper scissors game I'm making [closed]

making a rock paper scissors game to learn better bash. For some reason it's not liking my elif statements and I can't figure out why. Also if there are any better ways of doing this let me know, ...
0
votes
1answer
54 views

how to replace special characters in large text file in shell scripting [closed]

I have using for below command but I have replaced special characters some characters is replaced some one not replaced that is my equation. sed "s/\,/\&\#44\;/g" VENKAT.TXT|sed "s/Décor/D\&...
2
votes
3answers
44 views

rename(1)-like script in Perl, but for copying files?

So there's this rename(1) Perl thing. It suits my task precisely, except that I need it to basically cp files instead of mv. How to achieve that? I have quite a few rules of renaming, all expressed ...
1
vote
2answers
65 views

Wait until a process comes back from sleep

script.sh is run by run.sh N times in parallel. For N=1, the script.sh process is set to sleep 30-45 seconds before it actually starts. How can I order ALL script.sh instances for N>1 not to start ...
1
vote
2answers
89 views

Copy files that are created today without FIND command and SFTP to another server

I have a directory with 'n' number of files in it. I am trying to write a shell script which will list only the files created on the particular day the script is running, and will use sftp to move the ...
1
vote
2answers
6k views

how do I run a cron job with a specific user?

My cron and scripting skills are very poor, but I need to run a job every 5 minutes by user 'cpc'. So I created a script and left it at /root. My crontab -e entry about it is: 0-59/5 * * * * /root/...
2
votes
1answer
107 views

Use xvfb to automate X program

I originally posted this question here, but upon second thoughts I decided here was a better place for this. I sadly have to use this proprietary program that bundles a camera driver. I want to ...
-1
votes
1answer
29 views

How to record numbers of array elements based on selection comparision criteria

I have many files which has many 2x2 arrays. In the present example I show only one file (file1) Input file(file1): 1: 6.1703 541.631 46.0391 2: 6.1930 537.446 45.9239 3: 6.1931 177.171 288.579 ...
0
votes
0answers
23 views

Execute custom script when wireless NIC connects to SSID

I have pieced together two scripts that will serve to execute a custom script when my wireless NIC connects to an SSID. Firstly, I will add the following (notice the post-up section): auto eth0 ...
0
votes
1answer
40 views

find: missing argument to '-exec'

this is my first post, as I am completely new to the programming world. Basically I'm taking a UNIX class and I have an assignment asking me to check the size of regular files in my home directory for ...
-2
votes
1answer
38 views

Unix shell scripting select and case statement

1) i want to write unix script which is like this echo "Do u want to check application logs ???" select opt in Yes No do case $opt in "Yes") commmands ;; "No") break ...
-2
votes
1answer
45 views

Write shell script for logging in servers and run command after logging in

I have wrote a shell script for logging into servers and run few commands to start and stop processes running on it, So I tried below code, but it is showing error, please help me with the script. ...
1
vote
1answer
64 views

Can a Linux server that authenticates against an Active Directory accept public/private keys for passwordless login?

I have a Linux server that authenticates users against an Active Directory. Now interactive logins require username and password and automatic login requires a keytab (Kerberos) for passwordless ...
0
votes
0answers
38 views

wgetting links that are written in script form - not plain html

I use wget to download all the html pages in an online gallery - in order to grab all the links to the full size images as follows: wget --wait=3 --user-agent=Webtography --no-cookies --timestamping -...
1
vote
1answer
45 views

Convert GPS coordinates with bash script

I need to convert to a specific format some gps coordinates which are the output of the exif information of a picture. This is the typical output: exif:GPSLatitude: 10/1, 10/1, 10/1 exif:...