Remove tab character from file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Remove tab character from file
# 1  
Old 01-21-2012
Remove tab character from file

I am trying to remove the tab character from a file, which occurs on two places in every line. So far I have tried the following and most are from threads in this forum:
Code:
sed -i '' -e 's/	/ /' file.dat
sed -i '' -e 's/[ \t]*/ /' file.dat
sed -i '' -e 's/\t*/ /g' file.dat
sed -i '' -e 's/[ \t]*//g' file.dat
tr "\011" " " file.dat
perl -i -pe 's/[ \t]+//' file.dat

I am using csh, so perhaps that is one of the reasons why none of these commands work. Is there a different command I should try?
# 2  
Old 01-21-2012
Hi.

What about the first option with a g modifier?

By "not work" you mean totally not work? The first option (with g) works for me in CSH.
# 3  
Old 01-21-2012
Thank you for your response. Here is the result of the first option and having added a 'g' modifier:
Code:
# sed -i '' -e 's/
s/ not found

# sed -i '' -e 's// /g' file.dat
sed: first RE may not be empty
#

Please note that I am entering the command only once, but is interpreted as a dual command on the command line.
# 4  
Old 01-21-2012
What OS are you using? Is CSH the login shell?
# 5  
Old 01-21-2012
I am using FreeBSD 8.2 and csh is the login shell indeed.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove newline character if it is the only character in the entire file.?

I have a file which comes every day and the file data look's as below. Vi abc.txt a|b|c|d\n a|g|h|j\n Some times we receive the file with only a new line character in the file like vi abc.txt \n (8 Replies)
Discussion started by: rak Kundra
8 Replies

2. Shell Programming and Scripting

Remove blank columns from a tab delimited text file

Hello, I have some tab delimited files that may contain blank columns. I would like to delete the blank columns if they exist. There is no clear pattern for when a blank occurs. I was thinking of using sed to replace instances of double tab with blank, sed 's/\t\t//g' All of the examples... (2 Replies)
Discussion started by: LMHmedchem
2 Replies

3. Shell Programming and Scripting

How to remove alphabets/special characters/space in the 5th field of a tab delimited file?

Thank you for 4 looking this post. We have a tab delimited file where we are facing problem in a lot of funny character. I have tried using awk but failed that is not working. In the 5th field ID which is supposed to be a integer only of that file, we are getting corrupted data as below. I... (12 Replies)
Discussion started by: Srithar
12 Replies

4. Shell Programming and Scripting

Remove the last character (,) for every line in a file

Good afternoon: im working wih 2 files to find differences and use the cmp command cmp file1 file2 file1 file2 are are diifferent char 302 line1 i found what the difference is with the sed command and that is the file1 at the end of every line has a (,) (comma) character. i.e sed -n... (4 Replies)
Discussion started by: alexcol
4 Replies

5. Shell Programming and Scripting

Remove ^L character from a file

Hello, I need to remove ^L character from a file as below: HELLO "I " HELLO "I " ^L HELLO "I" HELLO "I " HELLO "I " Please suggest. Thanks !! Please use next time code tags for your code and data (9 Replies)
Discussion started by: skhichi
9 Replies

6. Shell Programming and Scripting

How to remove the ^@ character in a file.

I receive a file which is Dos format. When I view the file using vi, I was able to find ^M, ^@ characters in beteen records. I wanted to remove these control/special characters. I used the dos2unix command. This removed the ^M characters. But I am unable to remove the ^@ character. I tried even the... (6 Replies)
Discussion started by: machomaddy
6 Replies

7. Shell Programming and Scripting

How to remove tab space and new line from a file using sed?

i am using the default sed package that comes with solaris. (11 Replies)
Discussion started by: chidori
11 Replies

8. Shell Programming and Scripting

How to remove first 2 character from file name

Hi All Please help me to remove the first 2 character from the file name. files are like this $ ls 12aman file 13atul si 56rana se I want to remove the first 2 char which are numbers. I want the o/p like thus aman file atul si rana se (8 Replies)
Discussion started by: atul9806
8 Replies

9. HP-UX

How to remove new line character and append new line character in a file?

Hi Experts, I have data coming in 4 columns and there are new line characters \n in between the data. I need to remove the new line characters in the middle of the row and keep the \n character at the end of the line. File is comma (,) seperated. Eg: ID,Client ,SNo,Rank 37,Airtel \n... (8 Replies)
Discussion started by: sasikari
8 Replies

10. Shell Programming and Scripting

Delete parts of a string of character in one given column of a tab delimited file

I would like to remove characters from column 7 so that from an input file looking like this: >HWI-EAS422_12:4:1:69:89 GGTTTAAATATTGCACAAAAGGTATAGAGCGT U0 1 0 0 ref_chr8.fa 6527777 F DD I get something like that in an output file: ... (13 Replies)
Discussion started by: matlavmac
13 Replies
Login or Register to Ask a Question