How do I catch the output of split and redirect it to another directory?for example,if my working directory is 'Documents' and I split a file called text.one into 4 files of 100 lines each (xaa, xab, xac, xad), how would I get those split files to be written into 'Directory/subdirectory' instead of 'Directory'?And is it possible to rename those split files so that the split name is suffixed with the original file's name e.g instead of xaa, xab... can they be written as text.one.xaa, text.one.xab..?I've thought about using '>' to send the output to a new directory but it doesn't work; and I've thought about piping the results to another command but I don't know what that other command should be.
So I've got a rather vast database, one of the columns is date in the following format: DD/MM/YY HH:MM:SS. This is starting to cause problems with a php page I'm writing which asks the user for a 'start date'. Would it be better for me to split the date column into date and say time? Or is there a way of using distinct and masking the times.
How can I split an output of a command to two terminals? one will get stdout and the other will get stderr. The best I could do is: On first terminal code...
This works ok but it prints the errors over and over again every time, is there any better way to redirect the errors to another terminal?
I'm currently teaching myself perl. I'm trying to write a program that unscrambles words by comparing each element in the array. There is an input file where you type the words to be unscrambled and there is a word list file containing approximately 1300 words. After everything has been processed the program is supposed to paste those words to an output file.
Code: #!/usr/local/bin/perl #use strict; #always add this in the beginning of code. #use warnings; #always add this in the beginning of code. #open(INFILE, '<', 'sample.txt'); # For reading #open(INFILE, '>', 'sample.txt'); # For writing #open(INFILE, '>>', 'sample.txt'); # To append .....
I have a file in which contains one line with a lot floating points.In the very first place and some times in the downstream, there are a few integers, surrounded by blank spaces.1 1.02-4 1.03-5 544 1.04-1 65 2.98-1 5.78-10 3.45-2 etc etc.I aim to split the file in more files each of them containing an integer and the following floatings until the next integer.
I need to grep a pattern which can be present in one line or could be split in 2 lines.Normal grep wont work in this case. Can anyone please help on this?There are 100's of files in which i need to search for this pattern so time is also a constrain.
If there's another way to improve a script that I have created, since I'm not an expert! It works, and it made what I wanted, but it took a while to do it... maybe it can be improved. Here's the background. I have one file, with 244000 lines, let's call it X. I needed to split it in 1000 files, each one of 244 lines. I also needed the files to have the .arp extension. So here is what I did:
Code: for i in {1..1000} do sed -n '1,244p;244q' X > $i.arp sed -i '1,244d;' X # in this way I deleted the copied lines each time done
I have an array called @logons. How can I step thru the array and split the fields? This is what I have so far, but doesnt work. I got the feeling I the split statement syntax is incorrect.
Code:
print @logons; foreach my $logons(@logons){ ($userid, $ip) = split(',',$logons);
[code]....
Update: Appears the data in @logons has a column header from the mysql query which I used to populate it with. So that code which I was testing does indeed work.
I have a large text file with three columns. I'm trying to write a PERL script that splits the file up based on the value of the 3rd column. So every time the third column reads 0, a new file is created and all the data up until the next 0 is found is written to that new file. This should happen over and over until the initial file has been entirely split up.
this might be an interesting one for the bash scripting gurus. I seem to break my teeth on it. The mission:- do a dd over ssh to trasnfer an image to another host- capture the dd PID on the other side- send a USR1 kill signal to it- capture that output on the original host It goes wrong on the last part. This is what I have before that step:dd if=image.gz | gzip -d | ssh host2 "dd of=/dev/vg1/lv1" &PID=`ssh host2 ps aux |grep dd|grep lx05|awk '{ print $2 }'`when I do "ssh host2 kill -USR1 $PIDI get nice outputs to the screen. When I replace the first line with:dd if=image.gz | gzip -d | ssh host2 "dd of=/dev/vg1/l01 2>/tmp/output.txt" &the dd command seemd to die. I suspect a problem with the pipe, since this does work when executing locally on a host without piping.
I'm running FC10, with the sendmail that was part of it in Feb 09. Anyway, Up till now I've been using the user client to do spam filtering, But I'd like to start catching the spam at the sendmail level. What are my options today? I tried searching the forums and found a bunch of threads from 2001-2006, but I figured many of the ideas are now longer vaild.
Solving issues with signed and unsigned numbers in BASH.For a start, Yes, BASH is type independent � I know that. My problem lays in catching executables output into a BASH variable.My executables are not quite UNIX compatible, where returned values are 0 for OK, >0 ERROR. They return 0 for OK, >0 WARNING (only, so move on) and <0 ERROR (abort) instead.
I followed this how to document [URL] to install postfix, Amavisd, SpamAssassin and ClamAV. My postfix installation is working fine and I can send and receive emails fine. However, it looks like SpamAssassin is not catching any emails. Emails do get passed over to Amavisd as I can see in the logs but ALL Messages comes out CLEAN without being tagged as spam.
As per the document, I did test by sending a test virus email
it does get delievered without being detected as SPAM or tagged as SPAM.
As I said, I have followed the documentation dot by dot and hence do not have spamassassin starting up as a service but i guess amavisd starts it within itself as a module.
Also, my postfix version is the one that supports mysql virtual tables which I got from rpmforge.
I've been trying to find a bug in this test script, but haven't been able to so far. I'm not lazy, I promise...just new to Bash so am having a hard time catching syntax errors. I call the script with the option -disableVenusBld, and it still prints "Starting build", which it shouldn't be doing right?
I've been debugging the following script all evening and am now stuck...this script is supposed to ssh to a router, pull interface conf, 'cut' 3 pieces of info, and then print the results of 2 as well as the 3rd (after running a ping cmd on the linux box):
As i am new to C++ i couldn't figure out how to input a file and make some change on the file and produce a output file. like this problem i have is.
"Program that processes an input file and produces an output file. The input file will contain lines of data, each containing two floating point numbers. The lines of the output file should contain the two numbers read and their average (with a '$' sign and 2 places after the decimal point)."
I have a file with something like** The total time for processing is 1245 seconds *when I doawk 'BEGIN{FS="The total time for processing"} {print $2 } ' fileI get correctly on screen 1245 seconds *but when I try to direct this to a file awk 'BEGIN{FS="The total time for processing"} {print $2 } ' file > outputthenoutput is empty ie the 1245 seconds * is not saved in ...Know why?
With the command "tail -300 /var/log/apache2/access.log | less" i can look in the log for the 300 latest visitors. and i wanted to ask if it's possiblle to get that command to run from a php file and if yes how ?