[bash] - Replace blank and string in csv file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [bash] - Replace blank and string in csv file
# 8  
Old 01-17-2017
Modified vgresh99 script
Code:
 awk -F';' ' /^;/ {next } FNR>1 { $2=($2) ? "Disabled":"Enabled"}1' OFS=';' file

This User Gave Thanks to looney For This Post:
# 9  
Old 01-17-2017
I'm sorry,
the file, before your suggestions is:
Code:
Login;Status
;
Luca;S 
Marco;
;
Stefano; 
Elettra;S 
;
Laura;
;
...

I need to delete line whit only ";" char.

Thanks.
# 10  
Old 01-17-2017
Which it does for me:
Code:
awk -F';' ' /^;/ {next } FNR>1 { $2=($2) ? "Disabled":"Enabled"}1' OFS=';' file
Login;Status
Luca;Disabled
Marco;Enabled
Stefano;Disabled
Elettra;Disabled
Laura;Enabled

What exactly is your problem?
This User Gave Thanks to RudiC For This Post:
# 11  
Old 01-17-2017
Quote:
Originally Posted by RudiC
Which it does for me:
Code:
awk -F';' ' /^;/ {next } FNR>1 { $2=($2) ? "Disabled":"Enabled"}1' OFS=';' file
Login;Status
Luca;Disabled
Marco;Enabled
Stefano;Disabled
Elettra;Disabled
Laura;Enabled

What exactly is your problem?
It's perfect!!
Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Detect blank spaces in a CSV file

I'm monitoring a WLAN network to keep track of new SSIDs popping up. The SSIDs are stored along with the AP MAC address and a few other parameters in a CSV file. A typical line could look like this: 18:70:9f:e3:80:aa 10:11:15 MyNetwork 2437 Now, the problem is that some networks use SSIDs... (4 Replies)
Discussion started by: Zooma
4 Replies

2. Shell Programming and Scripting

Assign variables to CSV string (bash)

Hi guys, New to the forum, and been messing around with Linux for about a year now. I'm still very much a rookie, so just assume that I'm a total idiot: I currently have a shell that spits out a CSV number string of about 8 numbers as follows: 1.00,2.00,3.00 ... ,8.00I need to assign a... (7 Replies)
Discussion started by: hansol
7 Replies

3. Shell Programming and Scripting

Inserting blank columns in already present CSV file

Hi, i have a csv file which have headers and values of it like below : headers --> CI Ref SerialNumber LastScanDate values --> VMware-42,VMware-42,Tue, 20 May 2014 11:03:44 +0000 i want to have a above csv in below format : headers --> CI Name CI Description CI Ref... (6 Replies)
Discussion started by: omkar.jadhav
6 Replies

4. Shell Programming and Scripting

Copying down first row in to all the below blank rows in a .csv file

Hi All, I have many of files(.csv) of the format given below. Date,Name,Location 04/02/2012,A,India ,B,China ,C,USA Like this I have 1000's of rows and many columns in all my files. I need a shell script to copy down the Date(in this example column1) to the next 2 rows below(in the... (8 Replies)
Discussion started by: ks_reddy
8 Replies

5. Shell Programming and Scripting

Text file to CSV with field data separated by blank lines

Hello, I have some data in a text file where fields are separated by blank lines. There are only 6 fields however some fields have several lines of data as I will explain. Also data in a particular field is not consistently the same size but does end on a blank line. The first field start with... (6 Replies)
Discussion started by: vestport
6 Replies

6. Shell Programming and Scripting

Replace 2nd column for each line in a csv file with fixed string+random number

Hi experts, My csv file looks like this U;cake;michael;temp;;;; U;bread;john;temp;;;; U;cocktails;sarah;temp;;;; I'd like to change the value fo 2nd column to cf+random number , which will look maybe something like this U;cf20187;michael;temp;;;; U;cf8926;john;temp;;;;... (7 Replies)
Discussion started by: tententen
7 Replies

7. Shell Programming and Scripting

How to remove Blank rows in a csv file

Hi, I need help to remove blank rows at the end of file. Sample data: "Oslo, Symra kino",Oslo,130-7,Symra 1,130-7-91 "Tønsberg, Brygga Kino SF",Tønsberg,202-1,Tønsberg SF 4,202-1-4 ,,,, ,,,, ,,,, ,,,, Expected data: "Oslo, Symra kino",Oslo,130-7,Symra 1,130-7-91 "Tønsberg, Brygga... (6 Replies)
Discussion started by: cnraja
6 Replies

8. Shell Programming and Scripting

Replace blank values for string using sed

Hi everyone, I was wondering how could from a file where each row is separated by tabulations, the row values where are in blank replace them by a string or value. My file has this form: 26/01/09 13:45:00 0 0 26/01/09 14:00:00 1495.601318 0 26/01/09 14:15:00 1495.601318 0 ... (4 Replies)
Discussion started by: tonet
4 Replies

9. Shell Programming and Scripting

how to replace a character with blank in a file

hi, I have a doubt in replacing characters with blank. My requirement is that, i have one file and looks like below 4:ALTER SYSTEM DISCONNECT SESSION '193,191' IMMEDIATE; 6:ALTER SYSTEM DISCONNECT SESSION '205,7274' IMMEDIATE; 5:ALTER SYSTEM DISCONNECT SESSION '206,34158' IMMEDIATE;... (4 Replies)
Discussion started by: sridhusha
4 Replies

10. Shell Programming and Scripting

Blank Space is not appending in each row of CSV File - Shell Script

I am calling SQL script in my UNIX Shell script and trying to create the CSV file and my last column value of each row is 23 blank spaces. In my SQL script,the last column is like below. RPAD(' ',23,' ') -- Padding 23 blank Spaces The CSV file is generated but the sapce(23 spaces) is... (2 Replies)
Discussion started by: praka
2 Replies
Login or Register to Ask a Question