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)

6
votes
1answer
677 views

Peculiar piping grep/head behavior

I'm helping the netadmin here with a perl regex to automate operating on some snapshots from our SAN and our scripts does stuff like this: varinit1=$(iscsiadm -m session | grep rbmsdata1 | head -n1 | ...
3
votes
2answers
815 views

is there any command like “wall” that runs a “command” in all terminals

as you know "wall" command sends a message to all terminals: wall message now my question is this: is there any command that can send a "command" to be run in all terminals? for example sending ...
4
votes
2answers
278 views

Exiting a pipeline if a former command fails

I'm trying to check the number of running and queued PBS jobs by parsing the output of qstat -tn1 from a bash script. So far, this has worked: count () { qstat -tn1 | awk ' BEGIN { R = 0; ...
4
votes
4answers
3k views

cut / grep and df -h

How can I grep or cut the "173G" under "Verf"? I need this for Unix scripting in school. jonas@jonaspc:~/$ df -h /dev/sda2 Dateisystem Größe Benutzt Verf. Verw% Eingehängt auf /dev/sda2 ...
0
votes
2answers
1k views

Re-assigning (specifically, incrementing) a variable in a bash script [duplicate]

Possible Duplicate: How can I do command line integer & float calculations, in bash, or any language available? I would like to simply re-assign a variable (to be specific, increment it ...
1
vote
4answers
531 views

Is learning a text editor like vi necessary and still worth the time today? [closed]

I started a new internship where all the servers run on AIX. Logging in for the first time I was suprised to see that my favorite text editor nano was not installed. Everyone here uses vi not ...
2
votes
4answers
2k views

chown all files based on file name pattern in current directory

I'm trying to chown all files whose filenames begin with ChownFileNames. I've used this command, but it doesnt seem to work: find . -maxdepth 1 |grep 'ChownFileNames*' -exec chown hadoop:hadoop -- {} ...
1
vote
2answers
554 views

Bash script to ftp only files of type gz in current directory

I have a bash script that cd to the right directory then uses the mput command to ftp all the files in the directory to a remote server, as below: for from_dir in $DATE_LIST do cd ...
4
votes
1answer
561 views

KTorrent: Moving data in a shell script

I'm trying to make a script for my magic folder that will move files to a seeding directory without KTorrent losing track of where the data is, similar to the "Move Data" context menu action in the ...
2
votes
4answers
2k views

Loop with 2 variables in a bash script

I am trying to utilize an API. I need to either do some type of "for loop" that replaces or utilizes 2 variables... In pseudo.. # Declare New Servers newserver=( box001 box002 box003 box004 box005 ...
3
votes
2answers
6k views

How can I trim the carriage return from text that is being piped in bash?

I'm using this command to get my last typed command: history | cut -c 8- | tail -n 2 | head -n 1 It works very well in bash, removing the line numbers, but there is one problem I have with it, (er, ...
4
votes
3answers
1k views

In linux, would it be possible to run a script every day 3 minutes later than the previous day?

My first solution to this was to execute date +%Y%m%d%H%M and put that format of numbers into a file, and run the script every minute from cron. Then if the date from the file matches the date ...
2
votes
2answers
284 views

Quick and dirty way to run a process more than once

I am looking for very simple bash script that would allow me to launch a process a few times. What's essential to me is that after the processes terminate, everything will clean up automatically. ...
1
vote
2answers
135 views

How to parse fields out of a text file and write them to another file

I have executed a database command and have generated an output file of the results. Each field name starts with dbt_xxxxxx Each field value is the value after the equal sign. how can I parse the file ...
-4
votes
2answers
1k views

How to write bash script that deletes the oldest file in a directory if there are greater than N files in the directory?

Wondering how would one go about writing a script that: Counts the number of files in a directory. If that number is greater than a specified number N, delete the oldest file in the directory. For ...
1
vote
1answer
1k views

How to open a local URL (webpage) on the command line

On MacOS X I can run open /some/path/index.html and this would open the page index.html with the default software that handles .html files. Is there something similar on Ubuntu Linux? I have used ...
2
votes
1answer
1k views

Shell script filtering through jpg files attributes

I'm trying to find a way to filter through thousands of jpg files, and keep only the files with a certain attribute (such as the camera brand with which the picture was captured). How can I do so?
7
votes
4answers
5k views

Parallel execution of a program on multiple files

I have a small script that loops through all files of a folder and executes a (usually long lasting) command. Basically it's for file in ./folder/*; do ./bin/myProgram $file > ./done/$file ...
2
votes
1answer
143 views

How do I detect whether changes in nano were discarded or saved?

I am currently writing a small setup script for a Linux application that needs the user to edit a configuration file before the application is started. I've chosen to make the script simply open the ...
4
votes
4answers
914 views

How to add a line to a file which has only root write permission and to continue the script execution

I am trying to learn bash scripting. I am working on a practical problem and at one point I need to add a line to a file which requires root permission to write. The code looks like this: # some ...
1
vote
2answers
831 views

how to detect command interpreter from within a shell script [duplicate]

Possible Duplicate: How to test what shell I am using in a terminal? For example the following script #!/bin/bash issue_interpreter_name would issue: bash
1
vote
2answers
1k views

How can I rewrite the From: address of an email and resend it?

I have a cPanel web hosting account. On this account I have a PHP-based support/trouble ticket system for my customers to use. I'd like to be able to send an email to both my customer and to the ...
4
votes
2answers
1k views

How can I run my own scripts in kate 3.8.2? “External tools” isn't available in the plugins section

I am using Kubuntu 12.04 LTS. How can I run my own scripts in kate 3.8.2? It appears that the plugin named External tools is no longer available. I would like to run Python or shell scripts in kate ...
3
votes
2answers
395 views

issues with GNU tail -f and combination of commands

$ tail -f /logs/filename.log | awk '!(/list)' I am able to run this command in GNU Linux flavour But when I written in a script it is not working. test.ksh: variable="/logs/filename.log | awk ...
4
votes
3answers
1k views

command line audio with mpg123 - how to save position in audio and begin from that location next time?

I am contemplating using mpg123 as an audiobook player. I can't find any other good audiobook players for Linux, and I think mpg123 may be my best option. My audiobooks are organized by directories ...
3
votes
3answers
4k views

using stat to provide timestamp for touch

Am trying to OCR some documents insitu (from a linux command line on a windows share). The process of OCRing is find and I have muddled through using the find command to pipe the files through the ...
2
votes
2answers
2k views

Scan for Network attached devices

Is there a way to scan for computers on the network through the command line and get their IP, MAC and DNS names without knowing anything about them?
4
votes
3answers
786 views

What does the following Bash script mean/do?

What does the following script mean? exec 4<&0 0</etc/XX/cfg read line1 exec 0<&4 UPDATE Thanks for the answer, just one part I'm not sure: It redirects fd0 to fd4, and ...
2
votes
2answers
229 views

Verify if a system has DVD burners?

Is it possible to verify if the system has a DVD burner installed? I need this for a script.
3
votes
2answers
2k views

How can I force a bash loop to end if it runs x times in x seconds?

I'm trying to grab batches of input from a remote pipe via ssh. My script below works ok, but I would like to add some sort of check into it so that if something were to go wrong or break the loop ...
4
votes
2answers
604 views

List of script( location)s that get run automatically, and when?

Does anybody know (of a resource listing) what scripts are run automatically, and when, from the moment I startup the computer until it's shutdown again. I know several places where I can add scripts ...
9
votes
6answers
932 views

Text Manipulation Across multiple lines

I Have a file that has text like this: AAAA BBBB CCCC DDDD 1234 5678 9012 3456 EEEE 7890 etc... And i want to match up the Alphabetic lines with the Numeric lines so they are like this: ...
2
votes
2answers
1k 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" | ...
4
votes
4answers
6k views

Backup of LVM2 logical volume

I'd like to make backup on external drive of LVM2 logical volume in dd manner. Approach I consider is to make lv on extranl drive with identical size copy with dd (Please let me know if you see ...
1
vote
1answer
2k views

Run expect inside a bash script as another user

I am writing a bash script to install some small software I'm developing. That script is run with sudo (as root), but some of the commands that are executed by the script need (or should be) run with ...
0
votes
2answers
274 views

How to generate Zipf-like samples, by using scripting language

Is there any scripting language function (like in python or bash) that samples from a zipf-like distribution, for exponent 0<a<=1. PS: I am aware of existence of a numpy function that can ...
3
votes
1answer
820 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 ...
4
votes
2answers
4k views

Sed: replacing digits

I am trying to write some install scripts for when I install/upgrade Ubuntu. I'm having trouble with fixing logrotate.d: /var/log/ufw.log { rotate 7 weekly missingok notifempty compress delaycompress ...
2
votes
3answers
609 views

dynamic display of a running process?

I am writing a script and acording to that when i run it certain info will be displayed on the output screen. for example say the constant data displayed is: my name is mukesh. i am 27 years old ...
0
votes
2answers
1k views

Need help to make rows into column with awk or sed

Recently, I look for scripts to take this: This; Is; First; Line; and make it like: This Is First Line
2
votes
1answer
1k views

Is there a shell utility for printing the contents of a plist? Preferably for a jailbroken iOS device?

I need a tool that prints the actual text in a plist file (plutil changes the format, cat prints gibberish, and there is no defaults command for iOS). It needs to be in a script, so text editors don't ...
6
votes
1answer
368 views

Is it possible to write portable service scripts to control a daemon?

I (or one of my colleagues) need to write one or more shell scripts to control the execution of a daemon. We need to be able to start the daemon, tell it to gracefully shut down, and force a shutdown. ...
5
votes
6answers
4k views

Linux script or program to shorten filenames

I haven't had much success in finding a Linux version of namemangler, which I need to rename 1000 of files so they are readable on Windows. Does anyone know of a Linux program that can do this? If ...
4
votes
3answers
346 views

Converting a history to a script?

Often times I've typed in a bunch of commands when I realize that I am going to keep typing them in and that I would really like a script. Now I understand that no matter how I save my history, I am ...
1
vote
1answer
71 views

Is S25mdadm start script priority correct?

(On Ubuntu 11.10 - configuration inherited from 10.10) Occasionally the boot process seems to suffer a race condition where a starting process misses some of the Raid-1 FSes, build via mdadm. ...
-3
votes
1answer
1k views

How to show the percentage progress of script execution in Unix?

Suppose you run some script such as a perl or tcl. For example, $ ./script.sh; ./script.pl; source script.tcl. It takes some time to get executed and return to prompt. How to display the percentage ...
0
votes
2answers
1k views

How to calculate in linux number of file inside nested directories?

I need to extract information how much files are in some directory tree: /.../testRoot/test1/test11/..../file1 /.../testRoot/test1/test11/file2 /.../testRoot/test1/test11/..../file3 ...
5
votes
1answer
2k views

Execute Script automatically at shutdown on Fedora 15/16

With fedora 15 or 16, I don't find the directory for execute a shell script automaticaly at shutdown...
1
vote
3answers
11k views

Pass command line arguments to bash script

I am new to bash script programming. I want to implement a bash script 'deploymLog', which accepts as input one string argument(name). [root@localhost Desktop]# ./deploymLog.sh name here I want to ...
-1
votes
2answers
251 views

Shell programming temp=$1 vs temp=1

What's the difference between temp=$1 and temp=1? Why do I need the dollar sign? For example: #!/bin/bash temp=$1 cell=$((($temp-32)*5/9)) echo $cell