Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Shell script to extract data from csv file Post 302847849 by krishmaths on Wednesday 28th of August 2013 02:43:39 AM
Old 08-28-2013
Assuming the header row is part of the input file

Code:
#!/bin/ksh
IFILE=/home/home1/name.csv
OFILE=/home/home1/name.csv.out
if [ -r $IFILE ]  #Checks if file exists and readable
then
  awk -F, '(NR==1){h2=$2;h4=$4;h5=$5;h6=$6;h7=$7;next} {print h2":"$2"\n"h4":"$4"\n"h5":"$5"\n"h6":"$6"\n"h7":"$7}' $IFILE > $OFILE
fi
cat $OFILE | mail -s "My data" abc@gmail.com

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script to Load data into the database using a .csv file and .ctl file

Since i'm new to scripting i'm findind it difficult to code a script. The script has to be an executable with 2 paramters passed to it.The Parameters are 1. The Control file name(.ctl file) 2. The Data file name(.csv file) Does anybody have an idea about it? :confused: (3 Replies)
Discussion started by: Csmani
3 Replies

2. Shell Programming and Scripting

shell-script which extract data from log file

give me a shell-script which extract data from log file on a server by giving date and time as input (for both start time and end time) and it will give the logs generated during the given time as output. (4 Replies)
Discussion started by: abhishek27
4 Replies

3. Shell Programming and Scripting

Help with shell script to extract data from XML file

Hello Scripting Gurus, I need help with extracting data from the XML file using shell script. The data is in a large XML and I need to extract the id values of all completedworkflows. Here is a sample of it. Input and output data is also in the attached text files. <wfregistry>... (5 Replies)
Discussion started by: yajaykumar
5 Replies

4. Shell Programming and Scripting

Exporting data as a CSV file from Unix shell script

Friends...This is the first time i am trying the report generation using shell script... any suggestions are welcome. Is there a way to set the font size & color when i am exporting the data from unix shell script as a CSV file ? The following sample data is saved as a .csv file in the... (2 Replies)
Discussion started by: appu2176
2 Replies

5. Shell Programming and Scripting

need a shell script to extract data from a log file.

If I have a log like : Mon Jul 19 05:07:34 2010; TCP; eth3; 52 bytes; from abc to def Mon Jul 19 05:07:35 2010; UDP; eth3; 46 bytes; from aaa to bbb Mon Jul 19 05:07:35 2010; TCP; eth3; 52 bytes; from def to ghi I will need an output like this : Time abc to def... (1 Reply)
Discussion started by: hitha87
1 Replies

6. Shell Programming and Scripting

How to extract data from csv file

Hello everybody, Here is my problem, I don't know anything about shell programming and my boss is actually asking me to develop a shell script in order to get values in a csv file from a specific date. Here is a sample of the csv file : Date;Enchaînement;Titre;Libellé ;calendrier;Heure début;Heure... (11 Replies)
Discussion started by: freyr
11 Replies

7. Shell Programming and Scripting

Read data from .csv file through shell script & modify

I need to read data from a file called "test.csv" through shell script where the file contains values like name,price,descriptor etc. There are rows where descriptor (& in some rows name) are written as string & other characters like "car_+" OR "bike*" etc where it should contains strings like... (3 Replies)
Discussion started by: raj100
3 Replies

8. UNIX for Dummies Questions & Answers

Shell script to extract data from csv file based on certain conditions

Hi Guys, I am new to shell script.I need your help to write a shell script. I need to write a shell script to extract data from a .csv file where columns are ',' separated. The file has 5 columns having values say column 1,column 2.....column 5 as below along with their valuesm.... (1 Reply)
Discussion started by: Vivekit82
1 Replies

9. Shell Programming and Scripting

Shell script to extract data from csv file

Hi everyone, I have a csv file which has data with different heading and column names as below. Static Data Ingested ,,,,,,,,,,,,Known Explained Rejections Column_1,column_2,Column_3,Column_4,,Column_6,Column_7,,% Column_8,,Column_9 ,Column_10 ,... (14 Replies)
Discussion started by: Vivekit82
14 Replies

10. UNIX for Beginners Questions & Answers

Shell script to extract data in a file

I have this 5GB file, and i want to extract from the file particulars pattern. this is my script: // count=`grep -wc "MSISDN" file_name` k=1 >OUTPUT >OUTPUT_Final while do cat file_name | awk -F":" -v var="$k" '$1=="MSISDN" {m++}m==var{print; exit}' >> OUTPUT cat file_name |awk -F":"... (33 Replies)
Discussion started by: gillesi
33 Replies
SG_RAW(8)							     SG3_UTILS								 SG_RAW(8)

NAME
sg_raw - sends an arbitrary SCSI command (with an optional data phase) to a device SYNOPSIS
sg_raw [OPTIONS] DEVICE CDB0 CDB1 ... DESCRIPTION
This utility sends an arbitrary SCSI command (between 6 and 16 bytes) to the DEVICE. For the optional data phase, data can either be read from a file and sent to the DEVICE or received from the DEVICE and then displayed or written to a file. The SCSI command may be between 6 and 16 bytes long. Each command byte is specified in plain hex format (00..FF) without a prefix or suf- fix. See EXAMPLES section below. The commands pass through a generic SCSI interface which is implemented for several operating systems including Linux, FreeBSD and Windows. OPTIONS
Arguments to long options are mandatory for short options as well. -b, --binary Dump data in binary form, even when writing to stdout. -h, --help Display usage information and exit. -i, --infile=IFILE Read data from IFILE instead of stdin. This option is ignored if --send is not specified. -k, --skip=LEN Skip the first LEN bytes of the input file or stream. This option is ignored if --send is not specified. -n, --nosense Don't display SCSI Sense information. -o, --outfile=OFILE Write data received from the DEVICE to OFILE. The data is written in binary. By default, data is dumped in hex format to stdout. If OFILE is '-' then data is dumped in binary to stdout. This option is ignored if --request is not specified. -r, --request=RLEN Expect to receive up to RLEN bytes of data from the DEVICE. RLEN may be suffixed with 'k' to use kilobytes (1024 bytes) instead of bytes. This option and --send are mutually exclusive. -s, --send=SLEN Read SLEN bytes of data, either from stdin or from a file, and send them to the DEVICE. This option and --request are mutually exclusive. -t, --timeout=SEC Wait up to SEC seconds for command completion (default: 20). Note that if a command times out the operating system may start by aborting the command and if that is unsuccessful it may attempt to reset the device. -v, --verbose Increase level of verbosity. Can be used multiple times. -V, --version Display version and license information and exit. EXAMPLES
sg_raw /dev/scd0 1b 00 00 00 02 00 Eject the medium in CD drive /dev/scd0. sg_raw -r 1k /dev/sg0 12 00 00 00 60 00 Perform an INQUIRY on /dev/sg0 and dump the response data (up to 1024 bytes) to stdout. sg_raw -s 512 -i i512.bin /dev/sda 3b 02 00 00 00 00 00 02 00 00 Showing an example of writing 512 bytes to a sector on a disk is a little dangerous. Instead this example will read i512.bin (assumed to be 512 bytes long) and use the SCSI WRITE BUFFER command to send it to the "data" buffer (that is mode 2). This is a safe operation. sg_raw -r 512 -o o512.bin /dev/sda 3c 02 00 00 00 00 00 02 00 00 This will use the SCSI READ BUFFER command to read 512 bytes from the "data" buffer (i.e. mode 2) then write it to the o512.bin file. When used in conjunction with the previous example, if both commands work then 'cmp i512.bin o512.bin' should show a match. EXIT STATUS
The exit status of sg_raw is 0 when it is successful. Otherwise see the sg3_utils(8) man page. AUTHOR
Written by Ingo van Lil REPORTING BUGS
Report bugs to <inguin at gmx dot de>. COPYRIGHT
Copyright (C) 2001-2008 Ingo van Lil This software is distributed under the GPL version 2. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR- POSE. SEE ALSO
sg_opcodes sg_vpd(sg3_utils), hdparm(hdparm), sgdiag(scsirastools) sg3_utils-1.26 May 2008 SG_RAW(8)
All times are GMT -4. The time now is 04:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy