Sponsored Content
Top Forums Shell Programming and Scripting awk - How to preserve whitespace? Post 302767375 by jnojr on Wednesday 6th of February 2013 06:28:45 PM
Old 02-06-2013
Quote:
Originally Posted by radoulov
With GNU awk >= 4 you could try something like this:
I'm on a Mac, and have to use the BSD tools that come with OSX, as I could not count on GNU tools being available :-(
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unable to assign value to variable using awk coz of whitespace in value

Unix gurus, I have a file as below, which is basically the result set obtained from a sql query on an Oracle database. ID PROG_NAME USER_PROG_NAME -------- --------------- ---------------------------------------- 33045 INCOIN Import Items 42690 ... (3 Replies)
Discussion started by: sunpraveen
3 Replies

2. Shell Programming and Scripting

How to match (whitespace digits whitespace) sequence?

Hi Following is an example line. echo "192.22.22.22 \"33dffwef\" 200 300 dsdsd" | sed "s:\(\ *\ \):\1:" I want it's output to be 200 However this is not the case. Can you tell me how to do it? I don't want to use AWK for this. Secondly, how can i fetch just 300? Should I use "\2"... (3 Replies)
Discussion started by: shahanali
3 Replies

3. Shell Programming and Scripting

Preserve space in variable of AWK

This seems to be a stupid basic question, but I cant get the space to stick in the awk variable. I do use this command to grep a time range of the log file. cat /var/log/daemon.log | awk '$0>=from&&$0<=to' from="$(date +%b" "%e" "%H:%M:%S -d -24hour)" to="$(date +%b" "%e" "%H:%M:%S)" I now... (9 Replies)
Discussion started by: Jotne
9 Replies

4. Shell Programming and Scripting

Date Format - preserve whitespace

I am trying to change the date format for the following: YESTER=`TZ=aaa24 date +%b" "%d | sed 's/0/ /'` TraceList=$(ls -ltR /pdt/logs | grep "$YESTER" | awk '{print $9}') CMD2=$(find /disk/dan/dansFiles/pass/logs/$TList -name cmd\* -prune) what I am trying to do in the above... (1 Reply)
Discussion started by: ther2000
1 Replies

5. Shell Programming and Scripting

Preserve trailing whitespace in variable

Hello, I wondering how I can echo a string without having the trailing whitespace removed. For example I have a string str="TESTING123 " that I need to hash using sha1. I get the correct answer when I run the line below from the terminal $ echo -n "TESTING123 " | openssl sha1... (3 Replies)
Discussion started by: colinireland
3 Replies

6. UNIX for Dummies Questions & Answers

[Solved] How remove leading whitespace from xml (sed /awk?)

Hi again I have an xml file and want to remove the leading white space as it causes me issues later in my script I see sed is possible but cant seem to get it to work I tried sed 's/^ *//' file.xml output <xn:VsDataContainer id="1U104799" modifier="update"> ... (10 Replies)
Discussion started by: aniquebmx
10 Replies

7. Shell Programming and Scripting

How to preserve spaces in input fields with awk?

I'm trying to do something pretty simple but its appears more complicated than expected... I've lines in a text file, separated by the comma and that I want to output to another file, without the first field. Input file: file1,item, 12345678 file2,item, 12345678 file2,item, ... (8 Replies)
Discussion started by: Armoric
8 Replies

8. Shell Programming and Scripting

Awk: Dealing with whitespace in associative array indicies

Is there a reliable way to deal with whitespace in array indicies? I am trying to annotate fails in a database using a table of known fails. In a begin block I have code like this: # Read in Known Fail List getline < "'"$failListFile"'"; getline < "'"$failListFile"'"; getline <... (6 Replies)
Discussion started by: Michael Stora
6 Replies

9. Shell Programming and Scripting

awk to ignore whitespace in field

The awk below executes and update the desired field in my first awk. However, the white space between nonsynonymous SNV in $9 is being split into tabs and my attempt to correct this does not update the field unless it is removed. I am not sure what I am doing wrong? Thank you :). file1 ... (4 Replies)
Discussion started by: cmccabe
4 Replies

10. Shell Programming and Scripting

awk sed to repeat every character on same position from the upper line replacing whitespace

Hello is it possible with awk or sed to replace any white space with the previous line characters in the same position? I am asking this because the file I have doesn't always follow a pattern. For example the file I have is the result of a command to obtain windows ACLs: icacls C:\ /t... (5 Replies)
Discussion started by: nakaedu
5 Replies
NEWSYSLOG(8)						    BSD System Manager's Manual 					      NEWSYSLOG(8)

NAME
newsyslog -- maintain system log files to manageable sizes SYNOPSIS
newsyslog [-CFNPnrsv] [-a directory] [-d directory] [-f config_file] [-S pidfile] [-t timefmt] [[-R tagname] file ...] DESCRIPTION
The newsyslog utility should be scheduled to run periodically by cron(8). When it is executed it archives log files if necessary. If a log file is determined to require archiving, newsyslog rearranges the files so that ``logfile'' is empty, ``logfile.0'' has the last period's logs in it, ``logfile.1'' has the next to last period's logs in it, and so on, up to a user-specified number of archived logs. It is also possible to let archived log filenames be created using the time the log file was archived instead of the sequential number using the -t option. Optionally the archived logs can be compressed to save space. A log can be archived for three reasons: 1. It is larger than the configured size (in kilobytes). 2. A configured number of hours have elapsed since the log was last archived. 3. This is the specific configured hour for rotation of the log. The granularity of newsyslog is dependent on how often it is scheduled to run by cron(8). Since the program is quite fast, it may be sched- uled to run every hour without any ill effects, and mode three (above) assumes that this is so. OPTIONS
The following options can be used with newsyslog: -f config_file Instruct newsyslog to use config_file instead of /etc/newsyslog.conf for its configuration file. -a directory Specify a directory into which archived log files will be written. If a relative path is given, it is appended to the path of each log file and the resulting path is used as the directory into which the archived log for that log file will be written. If an abso- lute path is given, all archived logs are written into the given directory. If any component of the path directory does not exist, it will be created when newsyslog is run. -d directory Specify a directory which all log files will be relative to. To allow archiving of logs outside the root, the directory passed to the -a option is unaffected. -v Place newsyslog in verbose mode. In this mode it will print out each log and its reasons for either trimming that log or skipping it. -n Cause newsyslog not to trim the logs, but to print out what it would do if this option were not specified. This option implies the -r option. -r Remove the restriction that newsyslog must be running as root. Of course, newsyslog will not be able to send a HUP signal to syslogd(8) so this option should only be used in debugging. -s Specify that newsyslog should not send any signals to any daemon processes that it would normally signal when rotating a log file. For any log file which is rotated, this option will usually also mean the rotated log file will not be compressed if there is a dae- mon which would have been signalled without this option. However, this option is most likely to be useful when specified with the -R option, and in that case the compression will be done. -t timefmt If specified newsyslog will create the ``rotated'' logfiles using the specified time format instead of the default sequential file- names. The filename used will be kept until it is deleted. The time format is described in the strftime(3) manual page. If the timefmt argument is set to an empty string or the string ``DEFAULT'', the default built in time format is used. If the timefmt string is changed the old files created using the previous time format will not be automatically removed (unless the new format is very similar to the old format). This is also the case when changing from sequential filenames to time based file names, and the other way around. The time format should contain at least year, month, day, and hour to make sure rotating of old logfiles can select the correct logfiles. -C If specified once, then newsyslog will create any log files which do not exist, and which have the C flag specified in their config file entry. If specified multiple times, then newsyslog will create all log files which do not already exist. If log files are given on the command-line, then the -C or -CC will only apply to those specific log files. -F Force newsyslog to trim the logs, even if the trim conditions have not been met. This option is useful for diagnosing system prob- lems by providing you with fresh logs that contain only the problems. -N Do not perform any rotations. This option is intended to be used with the -C or -CC options when creating log files is the only objective. -P Prevent further action if we should send signal but the ``pidfile'' is empty or does not exist. -R tagname Specify that newsyslog should rotate a given list of files, even if trim conditions are not met for those files. The tagname is only used in the messages written to the log files which are rotated. This differs from the -F option in that one or more log files must also be specified, so that newsyslog will only operate on those specific files. This option is mainly intended for the daemons or programs which write some log files, and want to trigger a rotate based on their own criteria. With this option they can execute newsyslog to trigger the rotate when they want it to happen, and still give the system administrator a way to specify the rules of rotation (such as how many backup copies are kept, and what kind of compression is done). When a daemon does execute newsyslog with the -R option, it should make sure all of the log files are closed before calling newsyslog, and then it should re-open the files after newsyslog returns. Usually the calling process will also want to specify the -s option, so newsyslog will not send a signal to the very process which called it to force the rotate. Skipping the signal step will also mean that newsyslog will return faster, since newsyslog normally waits a few seconds after any signal that is sent. -S pidfile Use pidfile as syslogd(8)'s pidfile. If additional command line arguments are given, newsyslog will only examine log files that match those arguments; otherwise, it will examine all files listed in the configuration file. FILES
/etc/newsyslog.conf newsyslog configuration file /etc/newsyslog.conf.d Each file in this directory will be included by the default newsyslog.conf. /usr/local/etc/newsyslog.conf.d Each file in this directory will be included by the default newsyslog.conf. COMPATIBILITY
Previous versions of the newsyslog utility used the dot (``.'') character to distinguish the group name. Beginning with FreeBSD 3.3, this has been changed to a colon (``:'') character so that user and group names may contain the dot character. The dot (``.'') character is still accepted for backwards compatibility. SEE ALSO
bzip2(1), gzip(1), xz(1), syslog(3), newsyslog.conf(5), chown(8), syslogd(8) HISTORY
The newsyslog utility originated from NetBSD and first appeared in FreeBSD 2.2. AUTHORS
Theodore Ts'o, MIT Project Athena Copyright 1987, Massachusetts Institute of Technology BUGS
Does not yet automatically read the logs to find security breaches. BSD
September 23, 2014 BSD
All times are GMT -4. The time now is 08:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy