Adding a character in the beginning of every line in a .dat file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding a character in the beginning of every line in a .dat file
# 1  
Old 12-22-2005
Lightbulb Adding a character in the beginning of every line in a .dat file

How can i add a character(#) in the beginning of every line in a .dat file
# 2  
Old 12-22-2005
Code:
sed -i -e 's_.*_#&_' input.dat

# 3  
Old 12-22-2005
one more,

Code:
awk '{ printf "#"; print }' <filename>

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to use sed to insert character in the beginning of file path?

I need to manipulate one Database file on Solaris 11 in which contains more than 5000 lines of data file path like this: '/data1/oradata/DBNAME/system01.dbf', '/data7/oradata/DBNAME/undotbs1_01.dbf', '/data1/oradata/DBNAME/sysaux01.dbf', '/data28/oradata/DBNAME/userdata01.dbf', ... (6 Replies)
Discussion started by: duke0001
6 Replies

2. Shell Programming and Scripting

Adding test to beginning and end of list in a file

Hi all and apologies for the silly question, but I've searched and I can't get this right. I have a list of email addresses in a file that I need to blacklist (spam). the list is quite long and I would need to script a small routine so that I can get the following for each line in the file: db... (4 Replies)
Discussion started by: bm555
4 Replies

3. Shell Programming and Scripting

Adding a text in the beginning of a line

Hi, I am doing something like below: cat file1>file3and cat file2>>file3 I wanted to check if there is a way to write a custom message(hardcoded message)something like below at the beginning of each line then PIPE delimitiation and then followed by remaining record. cat file1... (7 Replies)
Discussion started by: Saanvi1
7 Replies

4. Shell Programming and Scripting

Adding end of line character in the last record

Need to add end of line character to last record in a fixed width file. When i take the record length of each line, for all the records it gives example like 200 except the last line as 199. Due to this my other script fails. Please help me on this. (4 Replies)
Discussion started by: Amrutha24
4 Replies

5. Shell Programming and Scripting

Adding new line character

Hi All, i am taking end of records using tail command got the out is "END OF FILE. ROW COUNT: 10" and record count in the file is 3. while append the both data into test2.txt file,it's append like END OF FILE. ROW COUNT: 108 my output should be in the test2.txt file END OF FILE. ROW... (9 Replies)
Discussion started by: bmk
9 Replies

6. UNIX for Dummies Questions & Answers

rename file by adding a name in beginning

about 200 files with names as 11_0.pdb 11_60.pdb 12_12.pdb 14_180.pdb are there in my library...I need to rename all of them by addinf File in front of them as: File11_0.pdb File11_60.pdb File12_12.pdb File14_180.pdb I checked many threads but it seems i get even more confused..i... (1 Reply)
Discussion started by: kanikasharma
1 Replies

7. UNIX for Dummies Questions & Answers

Adding one string at the beginning of each line in a file

Hi, I have file a.txt as below. I want to add one string root beginning of each line. Sample file a.txt aaa bbb ccc Sample output Root aaa Root bbb Root ccc Can any one help me on this? (6 Replies)
Discussion started by: siba.s.nayak
6 Replies

8. UNIX for Dummies Questions & Answers

Remove words beginning with a certain character from a file

Hi, how could you go about removing words that begin with a certain character. assuming that this character is '-' I currently have echo "-hello" | sed s/-/""/ which replaces the leading dash with nothing but I want to remove the whole word, even if there are multiple words beginning... (3 Replies)
Discussion started by: skinnygav
3 Replies

9. Shell Programming and Scripting

Adding a special character at the end of the line

I used following to add * at the end of the line in file1. It adds * at the end but has a space before it for some lines but some other lines it adds exactly after the last character. How do I take out the space ? sed 's/$/*/' file1 > file2 example: contents of file1 : ... (2 Replies)
Discussion started by: pitagi
2 Replies

10. Shell Programming and Scripting

adding a character in front of a line

Hi everyon, I am trying to search for a pattern in a file and add "//" to the begining of the file. lets say i want to comment out a line from my codes. the line that should be commented out contains the word "reset". i need to search for the word "reset" and comment out that specific line. is... (5 Replies)
Discussion started by: ROOZ
5 Replies
Login or Register to Ask a Question