Programming :: Direct Standard Output From Find Command?

Mar 26, 2010

I'm trying to pull out sections from a bunch of files. For one file, I use:

Code:
sed '/string1/,/string2/ !d' <filename.ext >newfilename.ext
to pull out everything between two strings in the original file and put them in a new file.

[code]....

View 3 Replies


ADVERTISEMENT

Programming :: Find Command With Standard Error Output And Mail Error File

Nov 11, 2010

We make everyday a DB Mysql backup on Linux redhat Enterprise. We are using a bash shell script (and putting it in the crontab) to execute it automatically everyday. We added a line to this script telling, once the backup has completed, to find old backup files (stored on hard disk after each backup) older than x days to remove them. We use the find command (search for file type) with the mtime option and in combination with rm command. Everything runs ok but we also want to add some new code to the same line: If find command cannot find anything or fails, for example if it cannot delete file or fails, send the error message (standard error output) to an error file (like error000001 and increasing) and mail the errorxxxx file to an email address for example to admin@companyname.com. What would be the code for this issue to add it to our find command in the same bash shell script??

View 2 Replies View Related

Programming :: Re-direct The Output Within An Awk Script?

Feb 27, 2011

I need to re-direct the output within an awk script, but not to already known, fixed filenames. The output file names depend on values of the fields. For example (the actual problem is surely more complicated), if, on a given line, the second field is DATA, the third is 1984, I would like to print some information in a file called output_DATA_1984. This could/would change in the following line of the same input file. Such things are pretty easy in bash, put I cannot do it in awk, as I can only find manual references for redirecting output to fixed filenames between double quotes.

View 2 Replies View Related

Programming :: Perl About System Command / Fails If The Standard Shell Is Dash And Not Bash?

Jun 30, 2011

I am trying to fix a perl script, and I really suck at perl. But I think this problem will be easy for people who know it.

The problem is, I have an old setup script someone wrote many years ago. It fails if the standard shell is dash and not bash. The only way I've gotten it to work is to point /bin/sh to bash. I looked thru the script and it uses "system" many places, and I think that's the problem.

I searched for it and found this link:url

My plan is to include this function:

Code:
sub system_bash {
my @args = ( "bash", "-c", shift );
system(@args);
}
Then I could simply change all calls to system into system_bash and it should work?

The parameter to the system calls is usually some variable. What if the parameter is a list already? Do I need to test for it somehow, and if it's a list, prepend "bash" and "-c" to the list? How do I do that?

In the script there are lots of places like this:

my $error = system($cmd);
if ($error) {
die/warn "some error message";
}

Shouldn't there be a return in the system_bash function?

View 8 Replies View Related

Programming :: Show The Output Of Shell Command Into A Textbox, Ex Ps -efc Command?

Oct 20, 2010

I am using gtk to program GUI. How can I show the output of shell command into a textbox, ex ps -efc command ?

View 3 Replies View Related

Software :: Use The Output Of The Find Command In The Bash Script?

Nov 17, 2010

I'm fairly new to writing bash scripts and haven't been able to find a an example of effectively using a the find command in a bash script.

I want to run some git commands on any sub directory that has a .git project in it. Getting to the directory is not my problem, its how to find them

What i want to do is execute

Code:
find -name .git

Then act on each response line that is printed out. E.G Navigate to the directory and run git status.

How do i use the output of the find command in the bash script?

View 6 Replies View Related

General :: Use '{}' To Redirect Output Of A Command Run Through Find's -exec Option?

Jan 10, 2011

I am trying to automate an svnadmin dump command for a backup script, and I want to do something like this:

find /var/svn/* ( ! -name dir -prune ) -type d -exec svnadmin dump {} > {}.svn ;

This seems to work, in that it looks through each svn repository in /var/svn, and runs svnadmin dump on it.

However, the second {} in the exec command doesn't get substituted for the name of the directory being processed. It basically just results a single file named {}.svn.

I suspect that this is because the shell interprets > to end the find command, and it tries redirecting stdout from that command to the file named {}.svn.

View 2 Replies View Related

OpenSUSE Multimedia :: Direct Output Of Microphone?

Nov 15, 2010

I would like to plug my guitar on my pc and hear what I'm playing out of my headphones. I have not found out yet how I can enable direct output. Neither with Line-In, nor Mic-Input worked. Has anyone an idea how to enable it? KMix does not provide such a function as far as I know

View 7 Replies View Related

Server :: Direct Cron Output In Text?

Apr 29, 2010

has no MTA (Postfix, Sendmail, Exim) installed so it can't email me the results of any cron job I schedule. I would then like to have the results from Cron be dumped into a small text file so I can read it later to view any issues.Right now my job is as follows:Code:01 18 * * * /usr/bin/shellscript.shAbove you see my script I want to run every day @ 6:01 pm. My question is what would the cron line look like if I wanted the results dumped into a random text file somewhere on my system?

View 1 Replies View Related

Programming :: Xargs With Output Of Find

Jul 15, 2011

I'm testing some multi-plat java code and I'm getting a bit frustrated with the Linux tests. I need to run the command:
Code:
$ java -jar /home/developer/TCO/TabletComicOptimizer.jar <file> <args[]>
against all the files that match a specific criteria. I've tried various find syntax and I can't seem to get it right.

Normally I would just create a bash script and populate the results of find into an array and then just enumerate the collection but in this specific case I want to demonstrate this operation at the bash terminal.

I've tried things like:
Code:
~/TCO $ find . -type f -iname "*.cb[rz]" | xargs java -jar TabletComicOptimizer.jar {} 1200x1800 ;
Thinking that the {} is the substitution for each file returned by find but it's not working. How do I execute my java program against each result in the find operation?

View 6 Replies View Related

General :: Run A Command Per File From The Output Of "find" Command?

Sep 8, 2010

I want to scan a particular directory recursively and run a particular command with each file as input. For this I am using "find /dir/path". I dont want to write any long script containing loop on the output of "find". I want a single command which will allow me to run a command on each file of the "find" command output.

View 3 Replies View Related

Programming :: Using Sed To Modify Command Output?

Jun 13, 2010

The output of a command changed and I need to extract the data and print it out in a different fassion:

Code:
abcd1=aaaa xx
abcd 2 aaa xx bbb
abcd2=aaaa xy
ab 2 xx aaa bbb ccc xxx
should be transformed to:

[Code]...

Currently I used sed "search1|search2|search3" to get the lines that need to be transformed. But I also need to search for substrings in those lines and I need to print those substrings in a specific order together with other characters. How is this done with sed?

View 7 Replies View Related

Programming :: Bash Ambiguous Redirect - Redirect One Command Output Which Will Be Treat As A Content Of File For Another Command?

Mar 9, 2011

I am trying to grep multiple numbers from file, grep does have the -f option for that.

Code: grep -f <`seq 500 520` /etc/passwd I know this could be done with

Code: for i in `seq 500 520`; do grep "$i" /etc/passwd; done But my question is fare more behind this example. It is possible to redirect one command output which will be treat as a content of file for another command ?

View 2 Replies View Related

Programming :: Echo Two Command Output In The Same Line?

Jan 25, 2011

I try to write script and echo two command at the same line .

echo "A"
echo "B"

How can I pipe above two command at the same line in text file . So, in the output text file , you can see below ? Code: A B not Code: A B

View 4 Replies View Related

Programming :: Diverting IDL Output To The Command Line?

Jul 14, 2010

I'm troubleshooting a batch of scripts I'm modifying, including an IDL script called by a .csh script. the IDL scripts were provided to me by a coworker and my .csh script is intended to automate a lengthy set of extremely tedious and time consuming processing tasks.

I am currently in the process of debugging, and can't get the IDL to print any messages other than critical failures to the screen. Is there any easy way to redirect the stdout to either a logfile or the screen?

View 2 Replies View Related

Programming :: Giving Output Of A Command As The Input To Another

Sep 7, 2010

While making a shell ,there is the following problem Im facing:

I am expecting the user to enter commands in the following format :

I am to separate these and the output of ls -l should be given as input to grep and the output of both to more.

But I am allowed (by our instructor) to use dup/dup2 or any other command(but not pipe or tees).

How to connect the file descriptors after successful execution of each command?

View 5 Replies View Related

Programming :: Get String From System Command Output ?

May 15, 2010

I have found this from a site [url]

Code:

But it does not work for me, segfault.

View 7 Replies View Related

Programming :: Store Output Of Command With Pipes?

Jan 20, 2011

I need to find one RUNNING word in latest created logs.
and as soon as i will get RUNNING WORD , i have to execute another Unix Command.

I wrote following script code...

View 3 Replies View Related

Programming :: Omit Specified Characters From The Output Of A Command?

Nov 18, 2010

After typing "man cut" in my terminal I can't seem to find this answer.

I am trying to write several shell scripts and want to remove the 'lp:<package name>' from the beginning of each line of the output of "bzr ls" as well as any notices at the beginning of the output, leaving only file and folder paths.

View 6 Replies View Related

Programming :: Using Bash Command To Execute Output Of Awk?

Mar 24, 2011

I am trying to process a column separated data file, with a few bash command. For example, I have

Code:

file1 aaaa yes
file2 aaaa no
file3 bbbb yes

Let say I want to create new file with the output of first column and do something else with the output of 3rd column. Of course there are many ways to process this data file, but I wish to know by using awk, how could I do it. I'm trying:

Code:

awk '{system("touch $1")}' datafile

but the shell command will not able to get the awk '$1' output. How do I get this done ? And for another question, if the data file contains the variable name of a shell variable, how could I make use of it during a awk output ? For example I have a datafile1:

Code:

server1 yes
server2 no

And in another server declaration data file, I got this datafile2:

Code:

server1=xxx1
server2=yyy1

And in my awk script, I want to achieve something like (the syntax is definitely wrong, just to demonstrate what I assume it will like):

[code]....

View 12 Replies View Related

Programming :: Script To Find Local IP - Output Unknown Host

Nov 24, 2010

I want to find out my IP and I test this code from beej tutorial:

Code:
char hostname[128];
int i;
struct hostent *he;
struct in_addr **addr_list;
struct in_addr addr;

gethostname(hostname, sizeof hostname);
printf("My hostname: %s
", hostname);
he = gethostbyname(hostname);
if (he == NULL) { // do some error checking
herror("gethostbyname"); // herror(), NOT perror()
return 1;
} // print information about this host:
printf("Official name is: %s
", he->h_name);
printf("IP address: %s
", inet_ntoa(*(struct in_addr*)he->h_addr));
printf("All addresses: ");
addr_list = (struct in_addr **)he->h_addr_list;

for(i = 0; addr_list[i] != NULL; i++) {
printf("%s ", inet_ntoa(*addr_list[i]));
}
printf("
");
return 0;

But my output is this:
Code:
My hostname: vBx
gethostbyname: Unknown host

I heard that it works in windows, why isn't working in linux?

View 1 Replies View Related

Programming :: Assigning Output Of A Command To An Array In Perl?

Nov 25, 2010

I am trying to execute a Unix Command in perl and assigning its output to an array:

Code:
@File_List=exec("ls -1 /tmp");
but it is not working. I have tried the perl function system() also but its return code is

[code]...

View 10 Replies View Related

Programming :: Receive Command Output And Store It To A Variable?

Apr 3, 2010

Suppose I want to account number of files beginning with abc , I can use "ls 'abc* | grep abc | wc -l", this will return me a number.
I want to store this number in a variable, say var1, so I tried
1. "ls 'abc* | grep abc | wc -l |read var1", but this didn't work as var1 has no value somehow.
2. var1='ls 'abc* | grep abc | wc -l', this just assign the entire string "ls 'abc* | grep abc | wc -l" to var1, which is not I wanted.

I don't want to store the value to a temporary file and then read the value from that file. I think there should be a direct way to get the value, but don't know how. I know in tcsh, one can just use set var1='ls 'abc* | grep abc | wc -l', but it also doesn't work in bash. Can anyone give any clue about this?

View 5 Replies View Related

Programming :: Organize Bash Script Output Of Which Is Like On Top Command

Sep 12, 2010

Is it possible to organize bash script output of which is like on top command i.e. monitoring every let's say 1 sec and old information would cleared?

View 3 Replies View Related

Programming :: Retrieving And Organizing Data From Command Output?

Mar 31, 2011

I was messing around with Bash scripting just now and was wondering if there was a way to organize the output of a command into an array. Like the Bash equivalent of the PHP explode() function.

View 3 Replies View Related

Programming :: Sort Command Output Differs When Encounters?

Mar 18, 2010

Here is what I am doing I have a file, a.txt for example, with following contents:

Code:
coreutils install
cpio install
cpp install
cpp-4.3 install
dbus install

[Code]...

So it seems like the sorting algo. for dpkg --get-selections is different than sorting algo. of 'sort' command when it encounters "-" (hyphen). How can I sort the original file (a.txt) in such a way that it produces the output file ,b.txt, exactly the same.

View 6 Replies View Related

General :: Clone Standard Output To /dev/tty0?

Jan 10, 2011

I'm working on a SBC9261 board with touchscreen, running Linux 2.6.24./dev/ttyS0 is the standard output and /dev/tty0 is the console on the touchscreen.What I would like to do is to clone the standard output to the touchscreen, so the console would be displayed twice.

It would be like :

Code:

~ $ ./whatEverScript > /dev/tty0

but the output would also appear on /dev/ttyS0.

View 2 Replies View Related

Programming :: Reading Command Output By Line In Bourne Script?

Feb 13, 2010

I have a command which generates the following output:

Code:
$ sudo vnconfig -l
vnd0: not in use

[code]...

View 6 Replies View Related

CentOS 5 :: Output Of 'yum List Installed' From A Standard 5.1 Installation

Mar 22, 2009

I would like to get the output from 'yum list installed' from a standard CentOS 5.1 32bit installation on a Intel desktop PC. I would like to do a diff with my 'yum list installed' to figure out exactly what my company customized. I know the docs here have the list of added, deleted and updated packages going from 5.0 to 5.1, but is there a complete 'yum list installed' list somewhere?

View 1 Replies View Related

Programming :: Creating Array From Command Output (Bash Shell Script)

Jan 26, 2011

I have a command that outputs n lines of text, and I want to place each line into an array element, but I can't seem to get the syntax correct

So my command is this:
cat $configfile | sed -n '/cluster:'$clustername'/,/cluster/ p' | awk /host/

Which produces many lines depending on the value of $clustername. I'd like to get each line as elements of an array.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved