Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Cat Input & Output to a Log file Post 302880228 by bartus11 on Wednesday 18th of December 2013 08:10:00 AM
Old 12-18-2013
You can do it like this:
Code:
echo cat a.txt > a.log
cat a.txt >> a.log

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

for i in `cat myname.txt` && for y in `cat yourname.txt`

cat myname.txt John Doe I John Doe II John Doe III ----------------------------------------------------------------------- for i in `cat myname.txt` do echo This is my name: $i >> thi.is.my.name.txt done ----------------------------------------------------------------------- cat... (1 Reply)
Discussion started by: danimad
1 Replies

2. Shell Programming and Scripting

how to input the CAT command output in Shell

Hi guys... I am new to this scripting...so please forgive me if anything worng in my questions... here is my question.. I have file structure /home/oracle/<sid>/logs/bkup now i want to write a script which should grep the sid name from a file..and it should replace the <SID> with... (1 Reply)
Discussion started by: troubleurheart
1 Replies

3. Shell Programming and Scripting

cat file and parse output

Hello, I'm new to shell scripting and did a search on the forum to what I want to do but couldn't find anything. I have about 9 routers that outputs to 1 syslog file daily named cisco.year.mo.date.log ex: cisco.2009.05.11.log My goal is to make a parsing script that cats today's syslog... (2 Replies)
Discussion started by: jjrambar
2 Replies

4. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

5. UNIX for Dummies Questions & Answers

Unable to copy file using SCP (Input/output & Permission denied error)

Hi, I am facing issue while using scp. Source & target machines are Linux & HP-UX respectively. On target machine, if I fire the following command, I get error: Now if I try scp on another file, which is on the same source machine, it works fine. All directories and subdirectories... (2 Replies)
Discussion started by: Technext
2 Replies

6. UNIX for Dummies Questions & Answers

Cat command drops lines in output file

I use the cat command to concatenate text files, but one of the rows I was expecting doesn't display in the output file. Is there a verbose mode\logging mechanism for the cat command to help me investigate where the lines I was expecting are going?? cat 7760-001_1_*_06_*.txt | grep -v... (1 Reply)
Discussion started by: Xin Xin
1 Replies

7. Shell Programming and Scripting

Cat writing only one record in the output file

Hi All, I have an input file containing data as below: Input.DAT XXXXXXX|YYYYYYY|ZZZZZZZZZZ|12334446456|B|YY|111111111|111111111|111111111|111111111|15|3|NNNNNN|Y|3|AAA|111111111... (11 Replies)
Discussion started by: sagar.cumar
11 Replies

8. Shell Programming and Scripting

Getting output from a file similar to cat output

I have a file # cat /root/llll 11 22 33 44 When I cat this file content to a variable inside a shell script and echo that shell script, it does not show up as separate lines. I need echo output similar to cat. cat /root/shell_script.sh #!/bin/bash var=`cat /root/llll` echo $var (2 Replies)
Discussion started by: anil510
2 Replies

9. Shell Programming and Scripting

Ssh cat file output into a file on local computer

Hello, I'm on a remote computer by SSH. How can I get the output of "cat file" into a file on the local computer? I cannot use scp, because it's blocked. something like: ssh root@remote_maschine "cat /file" > /locale_machine/file :rolleyes: (2 Replies)
Discussion started by: borsti007
2 Replies

10. UNIX for Beginners Questions & Answers

Print Error in Console and both Error & Output in Log file - UNIX

I am writing a shell script with 2 run time arguments. During the execution if i got any error, then it needs to redirected to a error file and in console. Also both error and output to be redirected to a log file. But i am facing the below error. #! /bin/sh errExit () { errMsg=`cat... (1 Reply)
Discussion started by: sarathy_a35
1 Replies
Log::Handler::Output::File(3pm) 			User Contributed Perl Documentation			   Log::Handler::Output::File(3pm)

NAME
Log::Handler::Output::File - Log messages to a file. SYNOPSIS
use Log::Handler::Output::File; my $log = Log::Handler::Output::File->new( filename => "file.log", filelock => 1, fileopen => 1, reopen => 1, mode => "append", autoflush => 1, permissions => "0664", utf8 => 0, ); $log->log(message => $message); DESCRIPTION
Log messages to a file. METHODS
new() Call "new()" to create a new Log::Handler::Output::File object. The following options are possible: filename With "filename" you can set a file name as a string or as a array reference. If you set a array reference then the parts will be concat with "catfile" from "File::Spec". Set a file name: my $log = Log::Handler::Output::File->new( filename => "file.log" ); Set a array reference: my $log = Log::Handler::Output::File->new( # foo/bar/baz.log filename => [ "foo", "bar", "baz.log" ], # /foo/bar/baz.log filename => [ "", "foo", "bar", "baz.log" ], ); filelock Maybe it's desirable to lock the log file by each write operation because a lot of processes write at the same time to the log file. You can set the option "filelock" to 0 or 1. 0 - no file lock 1 - exclusive lock (LOCK_EX) and unlock (LOCK_UN) by each write operation (default) fileopen Open a log file transient or permanent. 0 - open and close the logfile by each write operation 1 - open the logfile if C<new()> called and try to reopen the file if C<reopen> is set to 1 and the inode of the file has changed (default) reopen This option works only if option "fileopen" is set to 1. 0 - deactivated 1 - try to reopen the log file if the inode changed (default) How to use fileopen and reopen Please note that it's better to set "reopen" and "fileopen" to 0 on Windows because Windows unfortunately haven't the faintest idea of inodes. To write your code independent you should control it: my $os_is_win = $^O =~ /win/i ? 0 : 1; my $log = Log::Handler::Output::File->new( filename => "file.log", mode => "append", fileopen => $os_is_win ); If you set "fileopen" to 0 then it implies that "reopen" has no importance. mode There are three possible modes to open a log file. append - O_WRONLY | O_APPEND | O_CREAT (default) excl - O_WRONLY | O_EXCL | O_CREAT trunc - O_WRONLY | O_TRUNC | O_CREAT "append" would open the log file in any case and appends the messages at the end of the log file. "excl" would fail by open the log file if the log file already exists. "trunc" would truncate the complete log file if it exists. Please take care to use this option. Take a look to the documentation of "sysopen()" to get more information. autoflush 0 - autoflush off 1 - autoflush on (default) permissions The option "permissions" sets the permission of the file if it creates and must be set as a octal value. The permission need to be in octal and are modified by your process's current "umask". That means that you have to use the unix style permissions such as "chmod". 0640 is the default permission for this option. That means that the owner got read and write permissions and users in the same group got only read permissions. All other users got no access. Take a look to the documentation of "sysopen()" to get more information. utf8 If this option is set to 1 then UTF-8 will be set with "binmode()" on the output filehandle. log() Call "log()" if you want to log messages to the log file. Example: $log->log(message => "this message goes to the logfile"); flush() Call "flush()" if you want to re-open the log file. This is useful if you don't want to use option "reopen". As example if a rotate mechanism moves the logfile and you want to re-open a new one. validate() Validate a configuration. reload() Reload with a new configuration. errstr() Call "errstr()" to get the last error message. close() Call "close()" to close the log file yourself - normally you don't need to use it, because the log file will be opened and closed automatically. PREREQUISITES
Carp Fcntl File::Spec Params::Validate EXPORTS
No exports. REPORT BUGS
Please report all bugs to <jschulz.cpan(at)bloonix.de>. If you send me a mail then add Log::Handler into the subject. AUTHOR
Jonny Schulz <jschulz.cpan(at)bloonix.de>. COPYRIGHT
Copyright (C) 2007-2009 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-11-21 Log::Handler::Output::File(3pm)
All times are GMT -4. The time now is 11:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy