Sponsored Content
Top Forums Shell Programming and Scripting Need specific columns in a log file as excel. Post 302913729 by Akshay Hegde on Tuesday 19th of August 2014 02:19:35 PM
Old 08-19-2014
Try this script

Code:
#!/bin/bash

from="sender@domain.org"
to="receiver@domain.org"
subject="test subject"
body="test message"

# string more detail read this https://tools.ietf.org/html/rfc2046#section-5.1.1
boundary="ZZ_/afg6432dfgkl.94531q"


# add attachements...here...
attachments=( "adb.log" "mail.sh")



# function......
get_mimetype(){
  file --mime-type "$1" | sed 's/.*: //' 
}

# Build headers
{

printf '%s\n' "From: $from
To: $to
Subject: $subject
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary=\"$boundary\"

--${boundary}
Content-Type: text/plain; charset=\"US-ASCII\"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

$body
"
 
# now loop over the attachments
for file in "${attachments[@]}"; do

  [ ! -f "$file" ] && echo "Warning: attachment $file not found, skipping" >&2 && continue

  mimetype=$(get_mimetype "$file") 
 
  printf '%s\n' "--${boundary}
Content-Type: $mimetype
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=\"$file\"
"
 
  base64 "$file"
  echo
done
 
# print last boundary with closing --
printf '%s\n' "--${boundary}--"
 
} | sendmail -t -o

This User Gave Thanks to Akshay Hegde For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

use awk to read randomly located columns in an excel file

Hi, I have an excel file that have a random count of columns/fields and what im trying to do is to only retrieve all the rows under 2 specific field headers. I can use the usually command for awk which is awk 'print{ $1 $2}' > output.txt, but the location of the 2 specific field headers is... (9 Replies)
Discussion started by: mdap
9 Replies

2. Shell Programming and Scripting

how to convert fields from a text file to excel columns

i have this file which has the following contents: ,-0.3000 ,-0.3000 ,-0.3000 ,-0.9000 ,-0.9000 ,-0.9000 i would like to get this: -0.3-0.9-0.3-0.9-0.3-0.9 so far i am trying: awk '{for(i=1; i<=NF; i++) {printf("%f\n",$i)}}' test1 > test2 any help... (4 Replies)
Discussion started by: npatwardhan
4 Replies

3. Shell Programming and Scripting

How to sort columns in excel(csv) file

i want sort columns with headers based on another file headers file1 eg: i'm having an empty file with only coumn names like lastname firstname title expirydate stlcno status etc... another file with same column names and some other as well but in different order... file2 eg:firstname... (2 Replies)
Discussion started by: Man83Nagesh
2 Replies

4. Shell Programming and Scripting

Replace specific columns in one file with columns in another file

HELLO! This is my first post here! By the way, I think it is great that people do this. My question: I have two files, one is a .dilm and one is a .txt. It is my understanding that the .dilm file can be treated as a .txt file. I wrote another program where I was able to manipulate it as if it... (3 Replies)
Discussion started by: mehdib
3 Replies

5. UNIX for Dummies Questions & Answers

To compare first two columns in an excel file

Hi All, i have a excel sheet with two columns as below. column1 column2 100 100 200 300 300 400 400 400 500 600 i need to compare the values these two columns and the output should be printed in the third column...if these values are equal the output should be green and if these... (2 Replies)
Discussion started by: arunmanas
2 Replies

6. Shell Programming and Scripting

Converting specific Excel file tabs to CSV in Python

Hi list, This is probably something really simple, but I am not particularly familiar with Python so I thought I would ask as I know that python has an excel module. I have an excel document with multiple tabs of data and graphs. One of the tabs is just data which I require to have dumped to... (8 Replies)
Discussion started by: landossa
8 Replies

7. Shell Programming and Scripting

Transpose whole file and specific columns

Hi, I have a file like this a b c d e f g h i j k l Case1: I want to transpose the whole file Output1 a d g j b e h k c f i l Case2 Transpose a specific column - Say 3rd (6 Replies)
Discussion started by: jacobs.smith
6 Replies

8. UNIX for Dummies Questions & Answers

How to delete columns with numbers in an excel file?

Dear all, I have one file (see below) with more then 100 columns and 2500 rows, and need only column which has GType in label with Alphabets, please help me to remove these columns with numbers. input file is n.201.GType n-201.Theta n-201.R n_1.GType n_1.Theta n_1.R... (6 Replies)
Discussion started by: AAWT
6 Replies

9. Shell Programming and Scripting

Reading specific range of columns in an Excel file

Hi All, I want to read an excel file. PFA excel, I want to read the cloumn from A to G and the V to AH starting from Row number 3. Please help me on this. (7 Replies)
Discussion started by: Abhisrajput
7 Replies

10. Shell Programming and Scripting

Perl script to accept specific columns from excel

Hi All, I have below perl script which writes xml from .xls file. Now i want to add below two conditions in this script : 1. to check if the the input .xls file has ony two columns , if more tahn two columns then script should pop up an error. 2. If there are two columns , then first column... (4 Replies)
Discussion started by: omkar.jadhav
4 Replies
nfslogsum(8)						      System Manager's Manual						      nfslogsum(8)

NAME
nfslogsum - Summarize nfswatch log file SYNOPSIS
/usr/sbin/nfslogsum [-n] [-v] [logfile] OPTIONS
Directs nfslogsum to read only the first n entries in the log file. This is useful for summarizing log files in cumulative chunks. Pro- duces a verbose summary of the log file. DESCRIPTION
The nfslogsum command summarizes log files produced by the nfswatch program. By default the log file nfswatch.log is summarized; an alter- nate log file can be specified on the command line. Each nfswatch log file may contain one or more log sessions, each indicated by a header which is printed when logging is turned on. For each log session, nfslogsum tallies up the interval packet totals and prints out a one-page summary of the log session. Total packets and percentages are tabulated for each category and displayed. In addition to the summary information printed as described above, a summary of how many calls to each NFS procedure were made on each file system and individual file will be printed. This summary information is divided into three sections of six columns each. The columns are headed by the names of the following NFS procedures: Does nothing. This procedure is provided to allow server response testing and timing. Gets the file attributes (type, mode, number of links, owner's uid, owner's gid, size, access, modification and change times, and others). This procedure is used by the stat(2) system call, as well as several others. Sets the file attributes (mode, owner's uid, owner's gid, size in bytes, access and modification times). This procedure is used by system calls such as chmod(2), chown(2), and truncate(2). Gets the file system root. This procedure is obsolete, and has been replaced by a MOUNT protocol procedure. Looks up the file name. This proce- dure is used to obtain an initial file handle for use in current and future requests on that file, and is used by many different system calls. Reads from the symbolic link. This procedure is used by the readlink system call and by the kernel. Reads data from the file. This procedure is used by the read(2) system call. Writes to the cache. Unused in the current NFS protocol revision. Writes data to a file. This procedure is used by the write(2) system call. Creates a file. This procedure is used by the creat(2) and open(2) system calls. Removes a file. This procedure is used by the unlink(2) system call. Renames a file. This procedure is used by the rename system call. Creates a link to the file. This procedure is used by the link(2) system call. Creates a symbolic link to the file. This procedure is used by the symlink(2) system call. Creates a directory. This procedure is used by the mkdir(2) system call. Removes a directory. This proce- dure is used by the rmdir(2) system call. Reads entries from a directory. Generally only one READDIR call is needed per directory, since a variable number of entries can be returned. Gets file system attributes (transfer size, block size, blocks in use, blocks free). This pro- cedure is used by the statfs(2) system call. RESTRICTIONS
The nfslogsum utility is sensitive to the format of the log file produced by nfswatch. Do not edit or change the log file before using it as input to nfslogsum. SEE ALSO
Commands: nfswatch(8), tcpdump(8) Networking: bpf(7), packetfilter(7) nfslogsum(8)
All times are GMT -4. The time now is 08:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy