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)

1
vote
1answer
389 views

Replacing Evernote with Emacs and markdown - .org file list

I have grown tired of using evernote with wine or with any of the linux clients. I decided to change to Emacs and write all my notes in markdown so I can easily publish them in HTML and sync them with ...
2
votes
1answer
137 views

Mac equivalent application “shortcat”

There is a mac application called Shortcat and it make me envious. For those of you averse to clicking links here is a summary: Keep your hands on the keyboard and boost your productivity! ...
0
votes
2answers
524 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
3answers
416 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 ...
8
votes
3answers
5k views

End sox recording once silence is detected

I'm writing a script that uses sox to record me talking. Now I need sox to wait until it detects sound before it begins recording, and I do have that figured out. But I also need sox to exit once ...
0
votes
2answers
164 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
104 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
299 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
2answers
129 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
587 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 ...
0
votes
3answers
59 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
742 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
500 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
754 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
3answers
2k 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 ...
3
votes
1answer
267 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 ...
0
votes
1answer
97 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?
-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 ...
2
votes
1answer
12k 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 ...
3
votes
3answers
784 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 ...
1
vote
2answers
291 views

Automate input procedure to a binary file

I have a binary file on Unix, which when executed asks the user for inputs. The inputs to this binary file are given manually. I want to automate the procedure, since I know the inputs already. I ...
1
vote
4answers
655 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 ...
0
votes
1answer
1k 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 ...
5
votes
3answers
779 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?
1
vote
2answers
5k 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 ...
0
votes
1answer
260 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 ...
4
votes
2answers
523 views

Shell script printing the most visited directories

Is there a way to write a bash script with the following functionalities? Be launched when I press some key or key combination. (not so important requirement) Identify the 7 most visited directories ...
2
votes
3answers
206 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
187 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 ...
0
votes
2answers
526 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 ...
-3
votes
1answer
96 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. ...
3
votes
1answer
63 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 ...
0
votes
1answer
62 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 ...
20
votes
1answer
628 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/* ...
0
votes
1answer
93 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
263 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
2k 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, ...
3
votes
1answer
856 views

Auto-login to internet script

For me to connect to internet I need to login first. Normally I do this manually (by opening my browser then at the first URL I enter I am redirected to the ISP's login page). However there is a Perl ...
1
vote
1answer
390 views

Why ssh -nq -t can't see my environment variable?

I am executing a command on remote machine with -t flag ( to prevent the command from 'blocking' ) the prompt (somehow it works that way). So I am using ssh -nq -t root@ip but with this, the script ...
8
votes
6answers
1k views

Best way run a command on each file in a directory tree

There appear be a number of ways to do this including loops in shell script, find and xargs. Which of these is best, and which is most portable?
2
votes
2answers
3k 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 - ...
1
vote
1answer
709 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 ...
2
votes
2answers
96 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 ...
8
votes
4answers
3k 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
502 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 ...
0
votes
2answers
85 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 ...
3
votes
2answers
5k views

If Statement with 2 Variables - Bash

I am trying to write a single IF statement which can check two variables at once. I have two variables, for example: $VARA $VARB Both with either contain a 0 or a non 0 value. I need an if ...
1
vote
2answers
255 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 ...
4
votes
3answers
206 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 ...