Sponsored Content
Top Forums Shell Programming and Scripting Remove rows containing commas with awk Post 302928151 by senhia83 on Tuesday 9th of December 2014 11:14:07 AM
Old 12-09-2014
Try

Code:
awk  '{ split($2, subfield, ",");   if ( length(subfield)<2) print $0 }'

 

10 More Discussions You Might Find Interesting

1. Linux

How do i remove commas(,) & spaces

Hey guys, I am very much new to shell scripts. So you ppl may feel that i am asking stupid question here. :D 1. I am using command line argument as an input variable. The user gets this value in his mail from client which has commas n spaces (Eg. 12,34,56,789) and the scripts... (5 Replies)
Discussion started by: anushree.a
5 Replies

2. Shell Programming and Scripting

awk script to remove duplicate rows in line

i have the long file more than one ns and www and mx in the line like . i need the first ns record and first www and first mx from line . the records are seperated with tthe ; i am try ing in awk scripting not getiing the solution. ... (4 Replies)
Discussion started by: kiranmosarla
4 Replies

3. Shell Programming and Scripting

Remove duplicate commas after exporting excel file to csv

Hello everyone I'm new here and this is my first post so first of all I want to say that this is a great forum and I have managed to found most of my answers in these forums : ) So with that I ask you my first question: I have an excel file which I saved as a csv. However the excel file... (3 Replies)
Discussion started by: Spunkerspawn
3 Replies

4. Shell Programming and Scripting

shell script to remove extra commas from CSV outp file

Name,,,,,,,,,,,,,,,,,,,,Domain,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Contact,Phone,Email,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Location -----------------------,------------------------------------------------,-------,-----,---------------------------------,------------------------------------ ----... (1 Reply)
Discussion started by: sreenath1037
1 Replies

5. Shell Programming and Scripting

Remove rows with first 4 fields duplicated in awk

Hi, I am trying to use awk to remove all rows where the first 4 fields are duplicates. e.g. in the following data lines 6-9 would be removed, leaving one copy of the duplicated row (row 5) Borgarhraun FH9822 ol24 FH9822_ol24_m20 ol Deformed c Borgarhraun FH9822 ol24 ... (3 Replies)
Discussion started by: tomahawk
3 Replies

6. Shell Programming and Scripting

remove commas if touching any letters

I have a csv file that I am trying to edit. I need to remove any comma that is touching a letter. I used this command to find them. grep , moz_places_good.csv | head -n 10 | grep ,I would think I could use some form of this to just delete the commas and not the letter before it. Just not sure... (5 Replies)
Discussion started by: cokedude
5 Replies

7. Shell Programming and Scripting

Remove leading commas in the file

Hi , I have a file with below records 965382,10310858,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 767010,10217614,3,10217616,10217622,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,... (4 Replies)
Discussion started by: vputtas@gmail.c
4 Replies

8. Shell Programming and Scripting

Shell Code required -Output in Multiple Rows to be in single row separated by Commas -

Hola Greetings Experts , I have records spreaded across multiple lines. in attached log.txt i want output to be in 1 line like this below Atached as Output.txt. In brief Output related to 1 line is spreaded across multiple row I wanted it to be in 1 row . Please opem the file in notepad... (4 Replies)
Discussion started by: manishK
4 Replies

9. Shell Programming and Scripting

Remove quotes and commas from field

In the attached file I am trying to remove all the "" and , (quotes and commas) from $2 and $3 and the "" (quotes) from $4. I tried the below as a start: awk -F"|" '{gsub(/\,/,X,$2)} 1' OFS="\t" enhancer.txt > comma.txt Thank you :). (6 Replies)
Discussion started by: cmccabe
6 Replies

10. Shell Programming and Scripting

How to remove unwanted commas from a .csv file?

how to remove unwanted commas from a .csv file Input file format "Server1","server-PRI-Windows","PRI-VC01","Microsoft Windows Server 2012, (64-bit)","Powered On","1,696.12","server-GEN-SFCHT2-VMS-R013,server-GEN-SFCHT2-VMS-R031,server-GEN-SFCHT2-VMS-R023"... (5 Replies)
Discussion started by: ranjancom2000
5 Replies
DICTZIP(1)																DICTZIP(1)

NAME
dictzip, dictunzip - compress (or expand) files, allowing random access SYNOPSIS
dictzip [options] name dictunzip [options] name DESCRIPTION
dictzip compresses files using the gzip(1) algorithm (LZ77) in a manner which is completely compatible with the gzip file format. An extension to the gzip file format (Extra Field, described in 2.3.1.1 of RFC 1952) allows extra data to be stored in the header of a com- pressed file. Programs like gzip and zcat will ignore this extra data. However, dictd(8), the DICT protocol dictionary server will make use of this data to perform pseudo-random access on the file. Files in the dictzip format should end in ".dz" so that they may be distin- guished from common gzip files that do not contain the special header information. From RFC 1952, the extra field is specified as follows: If the FLG.FEXTRA bit is set, an "extra field" is present in the header, with total length XLEN bytes. It consists of a series of subfields, each of the form: +---+---+---+---+==================================+ |SI1|SI2| LEN |... LEN bytes of subfield data ...| +---+---+---+---+==================================+ SI1 and SI2 provide a subfield ID, typically two ASCII letters with some mnemonic value. Jean-Loup Gailly <gzip@prep.ai.mit.edu> is maintaining a registry of subfield IDs; please send him any subfield ID you wish to use. Subfield IDs with SI2 = 0 are reserved for future use. LEN gives the length of the subfield data, excluding the 4 initial bytes. The dictzip program uses 'R' for SI1, and 'A' for SI2 (i.e., "Random Access"). After the LEN field, the data is arranged as follows: +---+---+---+---+---+---+===============================+ | VER | CHLEN | CHCNT | ... CHCNT words of data ... | +---+---+---+---+---+---+===============================+ As per RFC 1952, all data is stored least-significant byte first. For VER 1 of the data, all values are 16-bits long (2 bytes), and are unsigned integers. XLEN (which is specified earlier in the header) is a two byte integer, so the extra field can be 0xffff bytes long, 2 bytes of which are used for the subfield ID (SI1 and SI1), and 2 bytes of which are used for the subfield length (LEN). This leaves 0xfffb bytes (0x7ffd 2-byte entries or 0x3ffe 4-byte entries). Given that the zip output buffer must be 10% + 12 bytes larger than the input buffer, we can store 58969 bytes per entry, or about 1.8GB if the 2-byte entries are used. If this becomes a limiting factor, another format version can be selected and defined for 4-byte entries. For compression, the file is divided up into "chunks" of data, each chunk is less than 64kB, and can be compressed into an area that is also less than 64kB long (taking incompressible data into account -- usually the data is compressed into a block that is much smaller than the original). The CHLEN field specifies the length of a "chunk" of data. The CHCNT field specifies how many chunks are preset, and the CHCNT words of data specifies how long each chunk is after compression (i.e., in the current compressed file). To perform random access on the data, the offset and length of the data are provided to library routines. These routines determine the chunk in which the desired data begins, and decompresses that chunk. Consecutive chunks are decompressed as necessary. TRADEOFFS
Speed True random file access is not realized, since any access, even for a single byte, requires that a 64kB chunk be read and decom- pressed. This is slower than accessing a flat text file, but is much, much faster than performing serial access on a fully com- pressed file. Space For the textual dictionary databases we are working with, the use of 64kB chunks and maximal LZ77 compression realizes a file which is only about 4% larger than the same file compressed all at once. OPTIONS
-d or --decompress Decompress. This is the default if the executable is called dictunzip. -c or --stdout Write output on standard output; keep original files unchanged. This is only available when decompressing (because parts of the header must be updated after a write when compressing). -f or --force Force compression or decompression even if the output file already exists. -h or --help Display help. -k or --keep Do not delete the original file. -l or --list For each compressed file, list the following fields: type: dzip, gzip, or text (includes files in unknown formats) crc: CRC checksum date and time: from header chunks: number of chunks in file size: size of each uncompressed chunk compr.: compressed size uncompr.: uncompressed size ratio: compression ratio (0.0% if unknown) name: name of uncompressed file Unlike gzip, the compression method is not detected. -L or --license Display the dictzip license and quit. -t or --test Check the compressed file integrity. This option is not implemented. Instead, it will list the header information. -v or --verbose Verbose. Display extra information during compression. -V or --version Version. Display the version number and compilation options then quit. -s start or --start start Specify the offer to start decompression, using decimal numbers. The default is at the beginning of the file. -e size or --size size Specify the size of the portion of the file to decompress, using decimal numbers. The default is the whole file. -S start or --Start start Specify the offer to start decompression, using base64 numbers. The default is at the beginning of the file. -E size or --Size start Specify the size of the portion of the file to decompress, using base64 numbers. The default is the whole file. -p prefilter or --pre prefilter Specify a shell command to execute as a filter before compression or decompression of a chunk. The pre- and post-compression fil- ters can be used to provide additional compression or output formatting. The filters may not increase the buffer size signifi- cantly. The pre- and post-compression filters were designed to provide the most general interface possible. -P postfilter or --post postfilter Specify a shell command to execute as a filter after compression or decompression. CREDITS
dictzip was written by Rik Faith (faith@cs.unc.edu) and is distributed under the terms of the GNU General Public License. If you need to distribute under other terms, write to the author. The main libraries used by this programs (zlib, regex, libmaa) are distributed under different terms, so you may be able to use the libraries for applications which are incompatible with the GPL -- please see the copyright notices and license information that come with the libraries for more information, and consult with your attorney to resolve these issues. SEE ALSO
dict(1), dictd(8), gzip(1), gunzip(1), zcat(1) 22 Jun 1997 DICTZIP(1)
All times are GMT -4. The time now is 08:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy