How do I stop printf output from going into seperate txt files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How do I stop printf output from going into seperate txt files
# 1  
Old 07-25-2006
How do I stop printf output from going into seperate txt files

I am using
Code:
printf "%-75s%+10s   %5s   %1s   \n" $s $z $x $y > status

It works really well, however, when I email status it is sending 10 emails when I would like it to be in one.

Is there a way to make all the output to go into one instance of a txt file. Yet still keep it 1 on each line?



Chris
# 2  
Old 07-25-2006
I think we need to see more of your script.
What do you mean by 10 emails? Ten separate emails sent to one person? Ten files?
# 3  
Old 07-25-2006
What I mean is whats supposed to happen is all of the output should go to one text file status. Whats happening is printf is copying one line at a time and creating a new status txt file every time.
Here is the almost completed script.

Code:
echo What is the account name?
read account
echo What is the email?
read email
echo How many hours?
read  hours
let t=$hours*60

find . ! -name '.*'  -type f -mmin "+$t" > holder
cut -c 3-70 holder > uploads
for f in $(<uploads); do s=`echo "$PWD/$f" | sed -e "s/^.*\.fileburst\.com/$account.fileburst.com/"`;z=`ls -la "$f" | awk '{ printf("%10d\n", $5)}'`; x=`ls -la "$f"| awk '{printf("%3s-%2s-%4s", $6, $7, $8)}'`;y=`md5sum "$f"| awk '{print $1}'`;
#echo -e "$s\t\t$z\t$x\t$y"
printf "%-75s%+10s   %5s   %1s   \n" $s $z $x $y > status

##mail -s "The following files have been uploaded to your directory chris2" -c "chris.collins@fuse.net" susant <  status
rm -rf uploads
rm -rf holder
done







When it emails status, it is also 1 email 1 line at a time.

Chris
# 4  
Old 07-25-2006
Try this one (I didn't test it, so it may be considered as pseudocode, just idea)

Code:
echo What is the account name?
read account
echo What is the email?
read email
echo How many hours?
read  hours
let t=$hours*60

find . ! -name '.*'  -type f -mmin "+$t" > holder
cut -c 3-70 holder > uploads
echo > status
for f in $(<uploads); do s=`echo "$PWD/$f" | sed -e "s/^.*\.fileburst\.com/$account.fileburst.com/"`;z=`ls -la "$f" | awk '{ printf("%10d\n", $5)}'`; x=`ls -la "$f"| awk '{printf("%3s-%2s-%4s", $6, $7, $8)}'`;y=`md5sum "$f"| awk '{print $1}'`;
#echo -e "$s\t\t$z\t$x\t$y"
printf "%-75s%+10s   %5s   %1s   \n" $s $z $x $y >> status

done

mail -s "The following files have been uploaded to your directory chris2" -c "chris.collins@fuse.net" susant <  status
rm -rf uploads
rm -rf holder
rm -rf status

# 5  
Old 07-25-2006
You are an absolute life saver! Thank you
# 6  
Old 07-25-2006
THIS IS A NEW ISSUE. I am having mail command problems.

Here is the code
[CODE]
printf "%-75s%+10s %5s %1s \n" $s $z $x $y >> status

mail -s "Uploads!" -c "chris.collins@fuse.net" susant < status




Here are the two issues-

1) the format that printf allowed me to have where my output was in columns is messed up when I mail it to an email address. It no longer lines up in columns.

2) The other issue is I am recieving multiple emails with this mail commad, instead of just 1??? I am not sure if this is a printf issue or a mail issue?

Chris
# 7  
Old 07-26-2006
1. Can you copy and paste the output of a mail received into a post so that users can see in what way the output is malformed. (Edit as required to remove personal information, but try to keep the same number of characters)

2. You will need to include more of your script. There does not appear to be anything in what you have posted thus far to cause the problem.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

For loop for seperate files

For shell script. If I had two separate files, file.txt and file1.txt and each has just a list of names from the who command. How would I create an if loop to compare each name? (1 Reply)
Discussion started by: Eric7giants
1 Replies

2. Shell Programming and Scripting

Desired output.txt for reading txt file using awk?

Dear all, I have a huge txt file (DATA.txt) with the following content . From this txt file, I want the following output using some shell script. Any help is greatly appreciated. Greetings, emily DATA.txt (snippet of the huge text file) 407202849... (2 Replies)
Discussion started by: emily
2 Replies

3. Shell Programming and Scripting

Compare two txt files,mismatches will be in new txt files

Hi, Below are the sample data for txt files. txt file 1 Partnumber|catgroup_id 10001082|46016 10001093|4680 10001093|386003 10001093|463004 10003251|683 10003251|63005 10003252|463005 10003252|4683 10003260|463005 10003260|4683 10003264|4683 10003264|463005 13420000|67... (5 Replies)
Discussion started by: Ankita Talukdar
5 Replies

4. Shell Programming and Scripting

printf Hexadecimal output

printf "%X\n" "A" 41 printf "%X\n" "2" 2 Expected 32 (not 2). Is there a "printf" which will output the hexadecimal value of a numeric character? (9 Replies)
Discussion started by: methyl
9 Replies

5. Solaris

list files .txt and .TXT in one command

Dear experts, In a directory i have both *.TXT and *.txt files. I have a script- for file in `ls *.txt`; do mv $file /tmp/$file How to list both *.txt and*.TXT file in one command so that script will move both .txt or .TXT whatever it find. br//purple (4 Replies)
Discussion started by: thepurple
4 Replies

6. UNIX for Advanced & Expert Users

Help please...output problems with printf.

#include <stdio.h> #include <math.h> // this function calculates the volume of a Cylinder int main(void) { int r; // radius int h; // height double M_PI; // pi int pOne = pow (r, 2); // get user input of radius and height printf ("Enter your... (3 Replies)
Discussion started by: pwanda
3 Replies

7. UNIX for Dummies Questions & Answers

comparing strings in seperate files

Hello, I am comparing files with for mismatches using fgrep but I've run into a problem. fgrep -vf $file1 $file2 > mismatches.dat file1 and file2 both contain file names on each line file1 has filenames which are up to 92 characters long and contain the "$" char. example file name:... (2 Replies)
Discussion started by: orahi001
2 Replies

8. Shell Programming and Scripting

Split File into seperate files

Hi, So I have a text file which I want to separate into separate text files. I would use the split command but the problem here is that the text file is separated by delimiters. For example: blah blah blah ------ more text ----- and some more text So basically the first part should be... (4 Replies)
Discussion started by: eltinator
4 Replies

9. Shell Programming and Scripting

Email like files in seperate emails

My goal is to send multiple files to a person based on their input. The files have similar names like: file1-egress-filter file2-ingress-filter stuff1-egress-filter stuff2-ingress-filter ... The script is run with the filename given as arguments, such as: ./mail.sh file stuff would... (6 Replies)
Discussion started by: earnstaf
6 Replies

10. Shell Programming and Scripting

Sorting problem "sort -k 16,29 sample.txt > output.txt"

Hi all, Iam trying to sort the contents of the file based on the position of the file. Example: $cat sample.txt 0101020060731 ## Header record 1c1 Berger Awc ANP20070201301 4000.50 1c2 Bose W G ANP20070201609 6000.70 1c2 Andy CK ANP20070201230 28000.00... (3 Replies)
Discussion started by: ganapati
3 Replies
Login or Register to Ask a Question