shell-scripting

How to send an email from unix script

#! /bin/bash `sqlplus -s <username>/<passwd>@dbname` << EOF set echo on set pagesize 0 set verify off set lines 32000 set trimspool on set feedback off `SELECT starts_with, SUM (total_records) total_records FROM (SELECT ID, (CASE WHEN ID LIKE '2%' THEN '2____' WHEN ID LIKE '3%...

What's wrong with this shell script?

I have this run as a Shell Script target in my Xcode project # shell script goes here genstrings -u -a -o en.lproj *[hmc] */*[hmc] */*/*[hmc] if [ -f "$PROJECT_DIR/build/Release-macosx/UnicodeEscape" ] then build/Release-macosx/UnicodeEscape "en.lproj/Localizable.strings" elif [ -f "$PROJECT_DIR/build/Debug-macosx/UnicodeEscape" ] t...

Sorting content based on first field and outputting second field into new file

I've got a file which is like this: 3 EOE 5 APPLE 6 NOBODY i need to parse this and output all with '3' in the first column into filename.3, '4' into filename.4, etc... from the unix prompt ...

Generating permutations using bash

is it possible to write a bash script that can read in each line from a file and generate permutations for each? Using awk / perl is fine. File ---- ab abc Output ------ ab ba abc acb bac bca cab cba ...

Use Quicktime to covert an audio file from AAC to AC3 via CLI?

Basically I want to use Quicktime to convert an audio file from AAC to AC3, I thought I might be able to use Quicktime? But I can't seem to be able to find the CLI command for it. ...

Internationalizing Bash scripts

I've been following a tutorial from a recent edition of the Linux Journal which teaches how to internationalize Bash scripts. However, I'm having trouble getting it to work on my system (Ubuntu 10.04.) When I get to the part where I'm supposed to call "gettext," after setting the environment variable TEXTDOMAINDIR, I get: toby@toby-lapt...

Shell Script for renaming and relocating the files

I am working on something and need to solve the following. I am giving a analogous version of mine problem. Say we have a music directory, in which there are 200 directories corresponding to different movies. In each movie directory there are some music files. Now, say a file music.mp3 is in folder movie.mp3 . I want to make a shell sc...

Add thousands of numbers stored in second 'column' in text files?

I've got a file with 400k+ numbers, each with a filename and its size in separate lines and I need to add them up to get a total. See: http://superuser.com/questions/195493/unix-recursive-directory-listing-with-full-pathname-of-file-and-filesize filename1 size1 filename2 size2 Its not going to be a very large number ... < ~50,000,000...

reformat java code

Hi again! I was working with a project that was saved in linux I opened it in a windows IDE and the strange thing is that it inserted break lines in all .java .jsp and other text files I like to remove all those empty lines recursively at the root directory of the project. Does anybody have some shell script that can I run to change th...

How to create required file name in unix using shell script

I am reading one property file which contains some file paths using shell script. Now depending on this file path I want to create name of zip file. Something like this...My property file contents:: path=tmp/inputs/logs/abc path=tmp/backup/inte/xyz destpath=abc/xyz Now I am able to create file name as abc.zip and xyz.zip as: paths=`g...

command not found error message after I try to run a UNIX script.

I'm learning how to make shell scripts in UNIX, but I keep coming across this stupid error. Let's say I make a script like this: #!/bin/sh echo HELLO I save the file as test, and make the command executable by me with chmod 700 test. I save the file in my home directory, and (attempt) to run the file like so: ./test Only for UNIX t...

How to set site in maintenance mode trough shell-script?

For my next project I will use automatic deployments with git. I can run a shellscript before and after deployment. Is it possible to set "maintenance" automatically with shell? In my .htaccess then I would check if a server variable is set to deployment or not to do the rewrite to maintenance? Is this possible and how should I handle ...

My shell script stops after exec

I'm writing a shell script that looks like this: for i in $ACTIONS_DIR/* do if [ -x $i ]; then exec $i nap fi done Now, what I'm trying to achieve is to list every file in $ACTIONS_DIR to be able to execute it. Each file under $ACTIONS_DIR is another shell script. Now, the problem...

In unix, how can I pipe the output of who into the groups command?

I'm trying to do something like this: Say there are 4 users logged into a UNIX machine, a, b, c, and d. Now, to get the groups these guys belong to, I have to type out : groups a b c d. What I am wondering, is if there is a way to do something like who | groups where I can pipe the users currently logged-in to the groups command, wh...

backing up subversion repositories

Hello, CentOS 5.3 subversion 1.4.2 I forgot to add. Currently the total repository size is about 5GB, but that will grow over time. We have our source code and documents on our internal server running CentOS 5.3 and we are using subversion 1.4.2. We are looking for a backup strategy. We want to perform daily backups. We have about 30...

How to run 'cd' in shell script and stay there after script finishes?

I used 'change directory' in my shell script (bash) #!/bin/bash alias mycd='cd some_place' mycd pwd pwd prints some_place correctly, but after the script finished my current working directory doesn't change. Is it possible to change my path by script? ...

list of file owners in folder on linux

I have a folder with many files. The files have been created by many different users. I do not know about shell scripting. I need to get the list of the username (only) of the owners of the files. I may save the output of ls -l and then parse it using perl python etc... But how can i do this using shell scripting? ...

How do I list one filename per output line in Linux?

I'm using ls -a command to get the file names in a directory, but the output is in a single line. Like this:. .. .bash_history .ssh updator_error_log.txt Is there a built-in alternative to get filenames, each on a new line, like this: . .. .bash_history .ssh updator_error_log.txt ...

How would I use grep on a single word in UNIX?

I want to run a script in unix that will look for a specific pattern inside a passed argument. The argument is a single word, in all cases. I cannot use grep, as grep only works on searching through files. Is there a better unix command out there that can help me? ...

UNIX "no match" error?

I'm trying to run the following: x=$(echo "$1" | egrep -c "^[0-9]|[:&^]") Now, this code is supposed to look for a word that starts with a number, or contains a :,& or ^. However,I geta "no match" error when I run this in UNIX. What makes matters more cofusing is that something similar runs well in terminal, but not in a script. ...