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 (1)

0
votes
3answers
275 views

Renaming all files in a directory while keeping the same initial part of the name [duplicate]

I have a directory full of files. I want to rename all the files that match *.py to -backup.py. How do I do that. I know I can use for i in *.py, but from there I'm not sure how to keep the ...
0
votes
2answers
483 views

sed - replace complex lines in a file using variables

How do I replace a complex line in a file using sed? For example I want replace a udev rule in /etc/udev/rules.d/70-persistent-net.rules. This doesn't work: OLD_RULE='SUBSYSTEM=="net", ...
0
votes
2answers
134 views

Merging multiple lines selectively?

I have a large file in which a header line is followed by a string of characters at multiple times. eg: file1 VHBFBJBDSBVVFJBSV SVJBVHJBVJ SVKJBVJBNVKVJV file2 dfhgdgffdghgg SVKJBVJBNVKVJV I ...
1
vote
1answer
95 views

bzr get last commit message using bash

I am using bash to try and get the last commit message of the most recent revision on a tree. In the documentation the closest thing I found was: bzr log -l 1 --line Which outputs: 45: Firstname ...
1
vote
2answers
241 views

What platform to use for programmatically editing text files? [closed]

I just volunteered at work for a project that involves creating a program to edit log files on a server. By edit I mean extract useful information to another location and remove lines of text that is ...
5
votes
3answers
213 views

${#array} vs ${#array[@]}

As far as I can tell both ${#array[@]} and ${#array} evaluate to the number of elements in $array. Is there any reason for preferring the longer form (${#array[@]})?
5
votes
2answers
122 views

Is there a less convoluted way to set the $path array locally within function?

Is there a less laborious way for setting a local version of the $path array than what's shown in the following snippet? foo () { local holdpath holdpath=($path) local path ...
2
votes
2answers
526 views

Add a suffix string to end of each line? [duplicate]

I have two files: file01: line1 line2 line3 file02: A B C And I want to get line1 A line2 B line3 C I could possibly write a Perl script but it is better if I don't need to. I have tried ...
3
votes
1answer
138 views

Using tcpdump to log blacklisted IPs

I am using tcpdump to log traffic outbound on a network. I would like to be able to log traffic on a host or IP-only basis but then I would like to be able to log large numbers of potentially ...
0
votes
3answers
56 views

how to compare total file

Suppose i have 2 config files such as: file 1: smtpd_sasl_auth_enable = yes broken_sasl_auth_clients = yes smtpd_sasl_authenticated_header = yes virtual_gid_maps = static:5000 File 2: ...
0
votes
1answer
639 views

Why is my shell script hanging on `apt-get -y upgrade`?

Ubuntu : sudo DEBIAN_FRONTEND=noninteractive apt-get -y update sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade sudo reboot Script is always interrupted after upgrade and then it will stay on ...
16
votes
4answers
476 views

Which folder should I write to for my intermediate files, as a dev?

I'm starting to write a few bash scripts for my project and they need some intermediate files or variables to be written. I want to know which folders can I be sure of having access to when someone ...
3
votes
2answers
968 views

Programatically use visudo to edit sudoers?

I have a sudoers file stored in our svn repo. I want to svn export it to /etc/sudoers but can't do it because sudo detects that it was not edited by visudo and throws syntax errors. What exactly does ...
12
votes
3answers
408 views

When to use redirection to stderr in shell scripts

I know that well-behaved utilities like grep output "normal" messages to stdout, and error messages to stderr. $ grep '^foo' file1 file2 file1:foo grep: file2: No such file or directory When I'm ...
0
votes
1answer
314 views

PuTTY and PowerTerm scripting Problem, Open a just in time URL via Samba share

I'm sshing into a fedora server using Powerterm (an expensive overly priced, license based, terminal emulator). The server uses an ancient form of (what I'm told is similar to) cobalt. I have no ...
2
votes
3answers
1k views

Replace filename with parent folder name

I have a bunch of files each in their own subdirectory. I need to write a script to rename each file to have the same name as its directory: For example, given: ./1111/1234.pdf ./2222/2345.pdf ...
0
votes
1answer
86 views

How can I use a variable from a script?

A bash script is running as I defined it in Startup Applications. It is possible to display on terminal a variable used in that script? If yes, how?
3
votes
1answer
223 views

Need script: latest JPEGs to video, then delete old JPEGs

I have an IP cam which uploads JPEG pictures to an FTP folder on my Arch Linux box whenever it detects movement in the room it is looking in. It uploads a JPEG every second until all motion activity ...
-2
votes
2answers
3k views

Loop over multiple addresses: ping and drop data into file

I would like to be able to have a script that will: look at a list of IP addresses Ping one of the addresses Take the data and drop it in to a file Move on to the next IP So far I have: cd ...
2
votes
1answer
3k views

Ssh to a box, run a command, output data to a file, then move on to the next IP adress [duplicate]

I want to run a script from my Jump server, have it SSH to a server, then run a command (like rm <file>, top or ls -lsa) then take that output and put it in to a file on my Jump server then move ...
3
votes
2answers
490 views

How can I determine if HTML5 player is running in browser?

I would like to find a command-line or a script that will show me if HTML5 player is running or not in a browser (firefox or chromium). For example, to determine if Flash player is running in a ...
2
votes
1answer
7k views

Copy multiple files into one (append, merge) in single invocation without shell redirection?

I'm looking for some sort of a command that I can use, to copy/append multiple files into one; but without shell redirection (I'd like to try it in call_usermodehelper, see similar issue in ...
2
votes
3answers
602 views

Help searching in files for regex patterns, recursively, with specialized output

My problem is that I need to: Find all lines matching regex_pattern in all files (deep search) in a given root directory For each line that matches, output: File name Line number containing the ...
0
votes
1answer
650 views

when to use double quotes with a variable in shell script? [duplicate]

I am in a confusion with what is meant by the double quotes referring to a variable. For example following two scripts gives the same output. What is really meant by the double quotes? Script1 ...
0
votes
1answer
234 views

Bash script installing within multiple directories [closed]

I am attempting to write a bash script that will install rbenv from beginning to end. I am on a Mac for interest sake. But there are some things that are not working mainly i am changing the ...
1
vote
2answers
4k views

Scrip to delete files older than 6 months

Setting up a cron job for once a month to start a script. the script is to rotate a file each month as it gets too big and rename the old one. when a file is older than six months I wanted it to be ...
2
votes
3answers
181 views

bash script selecting the last path variable

Hey all i am writing my first bash script. and i am making it install all the repos i have on github. warpInLocations=("git@github.com:acc/toolkit.git" "git@github.com:acc/sms.git" ...
-2
votes
1answer
150 views

bash script user promt for prefered directory

hey all i am attempting my first bash script. so i would like to prompt the user to find out where they would like a cloned repo to be saved currently i am assigning it like this ...
5
votes
3answers
700 views

Walking through files in directory randomly

How to change for track in *.mp3; do so that all .mp3 files in the current directory are walked through but in a random way?
0
votes
1answer
55 views

Utility script framework

We have a couple dozen utility scripts that run on various machines to do things like application level backups, pruning out old data, cleaning up disk space, etc. They were written by multiple ...
3
votes
1answer
60 views

Script not getting executed as per expectation

I have two Perl scripts at a predefined location in Unix. This predefined location is set in path variable ($PATH). Now when i try to run first script (from any location) the script runs successfully ...
-3
votes
1answer
91 views

Rename two files [closed]

I would like to rename two files files by using a script. E.g. mv plugin-cfg.xml plugin-cfg2.xml and mv plugin-cfgbk.xml plugin-cfg.xml I need to do this in multiple directories. ...
20
votes
1answer
609 views

How to move a directory, file by file? (instead of “copy then remove”)

My computer has one 500GB drive. I want to move 400GB of data from /unencrypted to /encrypted. Both directories are on the same partition, but /encrypted is handled by ecryptfs, so mv /uncrypted/* ...
2
votes
3answers
3k views

sed - how to replace a single quote?

This works fine: sed -i 's# @driver.find_element(:xpath, "//a\[contains(@href,##' temp_spec.rb against a source of @driver.find_element(:xpath, "//a[contains(@href,'change_district')]").click ...
0
votes
1answer
92 views

Use of .. in Linux scripting and makefiles [closed]

what is the use of .. in linux scripting and in the following makefile? MODULE = EQUALIZER = .. SRCS = include ${EQUALIZER}/xyz.mak include ${EQUALIZER}/pqr.mak
3
votes
2answers
234 views

How to monitor the last PID assigned by the kernel?

To monitor process creation I'd like to periodically write the last PID assigned by the kernel to any process on the system (not just processes created by the PID-monitoring program) with a time stamp ...
4
votes
3answers
1k views

How to share a GNU sed script between Linux and Mac OS X

I have a GNU sed script I use on Linux; it is installed at /bin/sed and it seems it contains GNUisms. I have collaborators using Mac OS X. They have installed (non-GNU) sed, located at /usr/bin/sed, ...
0
votes
2answers
430 views

How to create as many variables as needed from shell script(bash)?

I'm making a script for monitoring some user processes with Upstart but, since its for the company I work for, they asked me to do it generic...how's so? Well, the number of processes being monitored ...
2
votes
2answers
369 views

Commands for determining level of usage of server

I am scripting a new program that will connect to a cluster of machines in a VM park, and hopefully check their level of usage. The VM clients are a combination of RHEL and CentOS, and runs on ...
1
vote
4answers
547 views

Solaris: Script for finding the physical device path of all installed fiber cards

I have a number of systems (with quite varying type, generation and architecture unfortunately). I need to create a list of fiber cards on these varying systems. I am able to use prtconf -v, and ...
7
votes
4answers
2k views

How to constraint time a program runs in Linux?

I have several simulations to do, each is invoked with python simulate.py <parameter list>. The problem with these simulations is that some of them hang without quiting, which prevents me from ...
2
votes
2answers
2k views

/usr/bin/env: zsh -: No such file or directory

I get the error /usr/bin/env: zsh -: No such file or directory ...when I run an executable zsh script that starts with the following shebang line: #!/usr/bin/env zsh - Also, FWIW, replacing - ...
8
votes
4answers
2k views

Hybrid code in shell scripts. Sharing variables

This answer discusses how to run a multi-line Python snippet from the command line in a terminal. I noticed that the answer works great within shell scripts, even with nested indentation, which is ...
0
votes
1answer
425 views

Counting files on a remote server with ssh and an expect script

Below is my script to take count for files which are present in remote server. But it is not working. Please help me. #!/usr/bin/expect spawn ssh sduser@172.0.0.2 expect "123" send "123" interact ...
2
votes
2answers
93 views

Scripting to domain allocation to server

I have two text files: file #1: domain.txt cocacola.com airtel.com pepsi.com file #2: servers.txt 192.0.53.42 , 4 # 4 domains already allocated on server 192.0.53.42 192.53.1.2 , 1 # 1 ...
1
vote
1answer
591 views

How to clone a read-only portion of /proc file system

The problem with reading /proc file system is that it is not atomic. I tried using a library (procfs in Python) that wishes to read it, but it has glitches about 5% of the time because the process ...
0
votes
2answers
81 views

Executing a program according to the last modified date

I need to write a script which would execute some executables in a directory according to the last modified date. The oldest should run first. How do I do it? This is what I have done so far for f ...
1
vote
2answers
199 views

Direct recursive shell script output to each subdirectory, not parent directory

I'm processing a batch of subjects data recursively, calling the script within the parent directory. For example, I have the parent directory: /home/subjects and the subdirectories which contain ...
2
votes
1answer
240 views

Invoking a script with ld-linux.so?

I just downloaded a tar file that is supposed to include everything required to run a program that we can call some_binary. I extracted it's contents, and I see the following: A binary (let's call ...
4
votes
3answers
172 views

CD into directory from HISTORY in a bash script or alias e.g. $(!!)

I often want to change into the directory of a file on my file system, but I'm not sure where the file is. I search for it like so: find -type f -name "myfile.txt" Lets say for the sake of ...