help removing dashes from social security number


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers help removing dashes from social security number
# 1  
Old 02-28-2006
help removing dashes from social security number

I have a file containing social security numbers with the format ###-##-####. I need to read each record in this file, reformat the SSN to the format #########, and write the record with the reformatted SSN to a new file. I am a UNIX newbie. I think I need to use either the sed or awk commands, but I haven't had any success with them yet.

Thanks
Marcia P Smilie
# 2  
Old 02-28-2006
Do this:

echo 325-69-5555 | tr '-' ' ' | awk '{print $1$2$3}'

so if you had a file full of these you could also do:

cat fileWithSSN | tr '-' ' ' | awk '{print $1$2$3}'
# 3  
Old 02-28-2006
Some alternate methods...
Code:
$ echo 123-45-6789|sed 's/\(...\)-\(..\)-\(....\)/\1\2\3/'
123456789

$ echo 123-45-6789|awk -F - '{print $1 $2 $3}'
123456789

$ echo 123-45-6789|tr -d -
123456789

 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing large number of temp files

Hi All, I am having a situation now to delete a huge number of temp files created during run times approx. 16700+ files. We have never imagined that we will get this this much big list of files during run time. It worked fine for lesser no of files in the list. But when list is huge we are... (7 Replies)
Discussion started by: mad man
7 Replies

2. Shell Programming and Scripting

Removing cr,lf till number of fields are full

I have a file 1|2|3|4 a|b|c|d 1|2 3|4 a| b| c| d| The file should have 4 fields to load into a database. The file may have cr, lf, or end of line characters. What I want to see as output is 1|2|3|4 a|b|c|d 1|23|4 a|b|c|d I have tried (17 Replies)
Discussion started by: tampatim
17 Replies

3. UNIX for Dummies Questions & Answers

Removing setuid option for security.

According to Security standards given in https://www.stanford.edu/dept/as/ia/security/policies_standards/AS_standards/RH_linux_prod_sec_std_1.0.1.html Being a production system i want to implement the same on our server. but when i tried finding other files i got following output. # ls... (5 Replies)
Discussion started by: pinga123
5 Replies

4. Shell Programming and Scripting

Removing columns with dashes

My files look like this I need to remove the columns where dashes are the majority, if any of the sequences has any character in that particular position it should be removed too. The IDs and Freqs should be kept intact. Thus, the resulting file should look like this Thanks in advance (14 Replies)
Discussion started by: Xterra
14 Replies

5. Shell Programming and Scripting

removing files with certain number in the first row

Hello! I have 32000 files in a directory and want to remove those with first row beging with 0.00; file names are in numbers from 1 through 32000; I have coded the following but it gives me error: while ( i <= 32000 ) if (head -1 $i ==0.00) rm $i end Well, i am sure even if this... (14 Replies)
Discussion started by: nxp
14 Replies

6. Shell Programming and Scripting

Removing Zeros in front of a number

Hi All, I would like to trim the following input. My condition is as long as there's a zero on the left of the number, remove the zeros. Can anybody help me by using sed or awk ? Eg: 0011 => change to => 11 0333 => change to => 333 4444 => No change => 4444 (13 Replies)
Discussion started by: Raynon
13 Replies

7. Cybersecurity

Does anyone know any ways to protect social security number?

Hello everybody, I have been using my social security number for my taxation purposes. But, I have been recently intimidated by my lawyer that since the crime of identity theft has been on the high I should be careful in using it. I am really concerned about this and need to know whether there are... (1 Reply)
Discussion started by: shanekol
1 Replies

8. What is on Your Mind?

Social Security number?

We have now been living in Vence for 3 months. My husband works for a large IT company. How do we get hold of our Social Security numbers and Carte Vitale please? Thanks (4 Replies)
Discussion started by: shanekol
4 Replies
Login or Register to Ask a Question