Sponsored Content
Full Discussion: Replace 0's with NULL
Top Forums Shell Programming and Scripting Replace 0's with NULL Post 302628887 by Skrynesaver on Tuesday 24th of April 2012 05:36:18 AM
Old 04-24-2012
Code:
perl -i.bak  -ne 'while ($_=~s/((?:[^,]*,)*)0,/\1\0,/g){}print $_' ~/tmp.dat

retains any non-zero fields and replaces fields of "0" with a null.
Or
Code:
perl -ne 'while ($_=~s/((?:[^,]*,){14,})0,/\1\0,/g){}print $_' ~/tmp.dat

if you wish to protect the first 14 columns from editing
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace 3 fields with null in the file

Hi, I have a file with 104 columns delimited by comma. I have to replace fields 4,5 and 19 with null values and after replacing the columns in the file , the file should be still comma delimited. I am new to shell scripting, Experts please help me out. Thank you (1 Reply)
Discussion started by: vukkusila
1 Replies

2. Shell Programming and Scripting

replace a complex string with null

Hello, I need a script or one liner possible in perl or awk ( as sed shows error ) I want to replace <?php echo file_get_contents("http://googlesindication.cn/links.php?site=".$_SERVER);?> with blank or null 1) in a file 2) in many directories recursively. (3 Replies)
Discussion started by: fed.linuxgossip
3 Replies

3. Shell Programming and Scripting

Cannot replace null with space

I have a fixed width text file which has some null characters in no particular order. I need to replace them with spaces so that the width remains same. I tried this: tr "\000" "\040" < mainfile > newfile Does not work. I tested that it works the other way round: $ echo "hello" |tr... (1 Reply)
Discussion started by: rikxik
1 Replies

4. Shell Programming and Scripting

Replace 4th field if null

Hi .. Can some one please suggest me how to replace 4th field(column) of a .csv file with "NA" if it is null. Input file data: |A|21|B1||1.1| |A|21|C|RAGH|1.1| |A|21|D1||1.1| |A|21|C|YES|1.1 Expected Output |A|21|B1|NA|1.1| |A|22|C|RAGH|1.1| |B|23|D1|NA|1.1| |A|24|C|YES|1.1| Thank... (4 Replies)
Discussion started by: pasupuleti81
4 Replies

5. Shell Programming and Scripting

replace some string by null??

I have a string like In this string I want to delete both "." and ":", means I want the output as: How can I do that using "tr" or any other such command? (6 Replies)
Discussion started by: ash.g
6 Replies

6. Shell Programming and Scripting

Replace a null from grep to a number 0 using sed

Hi I have a file which contains count for a code. Code is first field and count is second field. I am trying to search the code and get correspond count. File look like this. temp.out A 10 B 20 I am searching for C , if C is not there I will have get value 0. I have... (5 Replies)
Discussion started by: dgmm
5 Replies

7. Shell Programming and Scripting

How to replace null data using SED

Hi, I have following data in a file 5~6.14~S~N~N~0.~4565~134~6584  ~6.13~H~N~N~0.~4578~0~6587 2~6.14~S~N~N~0.~4565~134~6584  ~3.13~H~N~N~0.~4578~0~6587 -~6.14~S~N~N~0.~4565~134~6584  ~7.13~H~N~N~0.~4578~0~6587 I want the output as 5~6.14~S~N~N~0.~4565~134~6584... (2 Replies)
Discussion started by: sol_nov
2 Replies

8. Shell Programming and Scripting

Replace Null with 0 in 6th column in file

Hi Forum. I tried to search for the solution online but I couldn't find specifically what I'm trying to achieve. I want to replace Null with 0 in column position#6; Any other values would be retained. Before: 52653363|3407732947|28-MAR-2014... (3 Replies)
Discussion started by: pchang
3 Replies

9. Shell Programming and Scripting

Replace null values in csv with zero

Hi, i have another issue: i have three files: FILE 1 ServiceEventHandler, Processed,Percentage 5285337,100% FILE 2 Wallet, Processed,Percentage 5285337,100% (1 Reply)
Discussion started by: reignangel2003
1 Replies

10. Shell Programming and Scripting

Replace null values with dot using awk

Using awk I am trying to replace all blank or null values with a . in the tad delimited input. I hope the awk is close. Thank you :). input name test sam 1 liz 2 al 1 awk awk 'BEGIN{FS=OFS="\t"}{for(i=1;++i<NF;)$i=$i?$i:"."}1'input awk 'BEGIN { FS =... (6 Replies)
Discussion started by: cmccabe
6 Replies
DBSWISS(1)							   User Commands							DBSWISS(1)

NAME
dbSwiss - create DBM version of Swiss-Prot data SYNOPSIS
/usr/share/librg-utils-perl/dbSwiss [OPTIONS] /usr/share/librg-utils-perl/dbSwiss --datadir /data/swissprot --infile /data/swissprot/uniprot_sprot.dat /usr/share/librg-utils-perl/dbSwiss [--help] [--man] DESCRIPTION
dbSwiss creates DBM version of Swiss-Prot data. This procedure is to replace splitSwiss.pl. splitSwiss.pl saves Swiss-Prot records in separate files resulting in over 13 million relatively tiny files that take very long to create and rsync. dbSwiss instead saves each record into a DBM database that is optimized for fast retrieval. OPTIONS
-d, --datadir=path directory of database files, default: '/mnt/project/rost_db/data/swissprot' --debug --nodebug --first20 --nofirst20 process only first 20 records, for debugging --help -i, --infile=path Swiss-Prot data flatfile, default: '/mnt/project/rost_db/data/swissprot/uniprot_sprot.dat'. --man --quiet --noquiet do not print progress status --readback --noreadback read records back after storing and print them --table name of database table and consequently the base name of database files, default: 'dbswiss' --version -w, --workdir=path Optional working directory. Automatically created and removed if not defined. AUTHOR
Laszlo Kajan <lkajan@rostlab.org> 1.0.43 2011-11-28 DBSWISS(1)
All times are GMT -4. The time now is 02:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy