I have a script that is inventorying (not sure if thats a word) my environment.
It goes out and pulls Hostname OS, IP, and ENV (dev, prod, etc)..then spits all that to a logfile
At the top of my script i have a check to see if the logfile exist.
What i want it to do is IF exist, do nothing...otherwise touch and echo header to file.
Currently every run it echos the header row.
I think you want something more like:
You have to redirect the output into the file you want it in instead of just writing it to stdout while it is directed to your terminal. But if you redirect it with the command form you're using you'll end up with an empty file because the shell redirection will create the file before the initial test checks for its existence.
Note that I used printf rather than echo because there are many different versions of echo. According to the standards the results are undefined if any of the arguments to echo contain a backslash character. Historically System V echo accepted \ escapes and BSD echo did not. System V echo didn't accept any options (and if it got initial arguments starting with - it printed them as part of the output) while BSD echo used a -n option to omit the terminating newline usually added to the output (System V echo used \c at the end to terminate output without a terminating newline). The printf utility should work the same on any UNIX-like system.
Hello,
I am building an .xls file extracting info from a DB to be eventually emailed. All is good except how do I put in a header row.. like date, name of report etc. before the columns with the actual column name and data?
Thanks for any assistance.. the below is after I have signed into... (11 Replies)
Hi All,
I need to BCP out a table into a text file along with the table headers. Normal BCP out command only bulk copies the data, and not the headers.
I am using the following command: bcp database1..table1 out file1.dat -c -t\| -b1000 -A8192 -Uuser -Ppassword -efile.dat.err
Regards,... (0 Replies)
Here is the csv file file i have:
ServerName, IPAddress, Gateway, Notes
ServerA, 192.168.1.100, 192.168.1.1, This is some server
ServerB, 192.168.1.110, 192.168.1.1, This is some other server
ServerC, 192.168.1.120, 192.168.1.1, This is some other other server
I would like to have the... (6 Replies)
Friends,
I need help with the following in UNIX.
Merge all csv files in one folder considering only 1 header row and ignoring header of all other files.
FYI - All files are in same format and contains same headers.
Thank you (4 Replies)
Hi! Is there a way to append column and row header to a file in awk script.
For example if I have
Jane F 39 manager
Carlos M 40 system administrator
Sam F 20 programmer
and I want it to be
# name gend age occup
1 Jane F 39 manager
2 Carlos M ... (4 Replies)
Hi All,
File contains header row.. we need to exclude the header row...no need to validate the first row in the file.
Data in the file should take valid data(two columns)..we need to exclude the more than two columns in the file except the first line.
email|firstname
a|123|100
b|345... (4 Replies)
Hi,
I have an input like this
1 2 3 4
2 3 4 5
4 5 6 7
I would like to count the no. of columns and print a header with a prefix "Col".
I would also like to count the no. of rows and print as first column with each line number with a prefix "Row"
So, my output would be
... (2 Replies)
Hi There!
I am saving the file count of all files in a directory to an output file using:
wc -l * > FileCount.txt
I get:
114 G4SXORD
3 G4SXORH
0 G4SXORP
117 total
But this count includes header and footer. I want to subtract 2 from the count and get
... (7 Replies)
Hi All,
i have script like ...
"TYPE_ID" "ID" "LIST_ID"
"18" "52010" "1059"
"18" "52010" "1059"
"18" "52010" "1059"
"18" "52010" "1059"
i am using the below code it's not taking the header row.
awk -F"\t" -v file=test1.txt -v file1=test2.txt ' {
if(... (7 Replies)
Hi,
So I am trying to print the first row(header) first column alongwith the matched value. But I am not sure how do I print the same, by matching a pattern located in the file
eg
File contents
Name Place
Jim NY
Jill NJ
Cathy CA
Sam TX
Daniel FL
And what I want is... (2 Replies)
Discussion started by: sidnow
2 Replies
LEARN ABOUT LINUX
bootlogd
BOOTLOGD(8) Linux System Administrator's Manual BOOTLOGD(8)NAME
bootlogd - record boot messages
SYNOPSIS
/sbin/bootlogd [-c] [-d] [-r] [-s] [-v] [ -l logfile ] [ -p pidfile ]
DESCRIPTION
Bootlogd runs in the background and copies all strings sent to the /dev/console device to a logfile. If the logfile is not accessible, the
messages will be kept in memory until it is.
OPTIONS -d Do not fork and run in the background.
-c Attempt to write to the logfile even if it does not yet exist. Without this option, bootlogd will wait for the logfile to appear
before attempting to write to it. This behavior prevents bootlogd from creating logfiles under mount points.
-r If there is an existing logfile called logfile rename it to logfile~ unless logfile~ already exists.
-s Ensure that the data is written to the file after each line by calling fdatasync(3). This will slow down a fsck(8) process running
in parallel.
-v Show version.
-l logfile
Log to this logfile. The default is /var/log/boot.
-p pidfile
Put process-id in this file. The default is no pidfile.
BUGS
Bootlogd works by redirecting the console output from the console device. (Consequently bootlogd requires PTY support in the kernel con-
figuration.) It copies that output to the real console device and to a log file. There is no standard way of ascertaining the real con-
sole device if you have a new-style /dev/console device (major 5, minor 1) so bootlogd parses the kernel command line looking for con-
sole=... lines and deduces the real console device from that. If that syntax is ever changed by the kernel, or a console type is used that
bootlogd does not know about then bootlogd will not work.
AUTHOR
Miquel van Smoorenburg, miquels@cistron.nl
SEE ALSO dmesg(8),fdatasync(3).
Jul 21, 2003 BOOTLOGD(8)