|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to remove space from each record in file?
Hi , I want to remove space from each record in one file My file is like Code:
BUD, BDL ABC, DDD, ABC ABC, DDD, DDD, KKK The o/p should be Code:
BUD,BDL ABC,DDD,ABC ABC,DDD,DDD,KKK Can any one help me regarding this? Last edited by Franklin52; 02-12-2013 at 08:40 AM.. Reason: Please use code tags for data and code samples |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
If you want to remove space anywhere in the file. Code:
sed 's/[ ]//g' file |
| The Following User Says Thank You to clx For This Useful Post: | ||
jagdishrout (02-12-2013) | ||
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Did you mean, to do in a shell script?
sed 's/ //g' MyFile |
|
#4
|
|||
|
|||
|
Code:
cat temp |sed 's/, /,/g'>newtemp |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
Code:
tr -d ' ' < infile > outfile @kg_gaurav, would you elaborate on the significance of using cat in your pipeline? |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Quote:
i considered all data like BUD, BDL ABC, DDD, ABC ABC, DDD, DDD, KKK are in file temp. so cat that and pipped with sed. well i usually use pipe you may directely use Code:
sed 's/, /,/g' temp >newfile |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Code:
awk '{ gsub(/,[ ]/,",",$0); print }' fileLast edited by Franklin52; 02-12-2013 at 08:40 AM.. Reason: Please use code tags for data and code samples |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| To remove a particular record from File | SatishW | Shell Programming and Scripting | 5 | 01-06-2010 02:07 PM |
| Remove particular record from a file | devmns | Shell Programming and Scripting | 4 | 10-07-2009 03:11 AM |
| To remove the record from a file | laxmi131 | UNIX for Advanced & Expert Users | 1 | 12-17-2008 06:54 AM |
| How to remove a particular record from a file? | kanu_pathak | Shell Programming and Scripting | 9 | 07-22-2008 09:34 AM |
| Remove First and Last Record from a file | ravikuc | UNIX for Dummies Questions & Answers | 1 | 10-11-2007 03:35 AM |
|
|