Search Results

Search: Posts Made By: kamose
6,130
Posted By RudiC
Which it does for me: awk -F';' ' /^;/ {next }...
Which it does for me:
awk -F';' ' /^;/ {next } FNR>1 { $2=($2) ? "Disabled":"Enabled"}1' OFS=';' file
Login;Status
Luca;Disabled
Marco;Enabled
Stefano;Disabled
Elettra;Disabled
Laura;Enabled
...
6,130
Posted By looney
Modified vgresh99 script awk -F';' ' /^;/...
Modified vgresh99 script

awk -F';' ' /^;/ {next } FNR>1 { $2=($2) ? "Disabled":"Enabled"}1' OFS=';' file
6,130
Posted By Don Cragun
Hi looney, Note that the above code changes the...
Hi looney,
Note that the above code changes the first line of input:
Login;Statusto:
Login;Enabled
but the desired output showed that that line was not supposed to be changed.

To meet the...
6,130
Posted By looney
bashwhile IFS=";" read f1 f2 do [[ $f2 ==...
bashwhile IFS=";" read f1 f2
do
[[ $f2 == "S" ]] && echo "$f1;Disabled" || { echo "$f1;Enabled" ;}
done < file
6,130
Posted By Scrutinizer
Another variation: awk '$2=="S"{$2="Disabled"}...
Another variation:
awk '$2=="S"{$2="Disabled"} $2==""{$2="Enabled"}1' FS=\; OFS=\; file
6,130
Posted By RavinderSingh13
Hello kamose, If you have only 2 fields as...
Hello kamose,

If you have only 2 fields as shown in your sample Input_file then following may help you too.

awk -F";" '{printf("%s;%s\n",$1,($2==""?"Enabled":((NR==1)?$2:"Disabled")))}' ...
6,130
Posted By vgersh99
awk -F';' 'FNR>1 {$2=($2)?"Disabled":"Enabled"}1'...
awk -F';' 'FNR>1 {$2=($2)?"Disabled":"Enabled"}1' OFS=';' myFile
1,299
Posted By Don Cragun
If you save the script vgersh99 suggested in a...
If you save the script vgersh99 suggested in a file named kam.awk, you need to use the same name in the command line when you invoke awk:
awk -f kam.awk Milano Torino Firenze
I assume the <comma>...
3,116
Posted By RudiC
Please use code tags as required by forum rules! ...
Please use code tags as required by forum rules!

awk -F";" 'length($1) > 7 {print > "log";next} 1' file > TMP && mv TMP file
Showing results 1 to 9 of 9

 
All times are GMT -4. The time now is 02:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy