Remove # sign from the file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove # sign from the file
# 8  
Old 02-05-2009
Code:
sed '2,8s/^.//;17s/^.//;30s/^.//' file

# 9  
Old 02-05-2009
naaah, I don't think OP can assume a static file layout - what matters is the 'scope' of the matching {}-s (I think).
Let's see if this is what the OP is looking for:

nawk -f asi.awk myFile

asi.awk:
Code:
/trap = {/ {blockOUT++}
/^# *{/ {blockOUT++}
blockOUT<=3 {sub("^# *", "   ")}
/^# *}/ {blockOUT--}
1


Last edited by vgersh99; 02-05-2009 at 06:40 PM.. Reason: fix for the trailing/last '}'
# 10  
Old 02-05-2009
quick and easy

sed -i 's/^#//g' filename
# 11  
Old 02-05-2009
Quote:
Originally Posted by jhefner
sed -i 's/^#//g' filename
once again - reread the OPs requirements:
Quote:
Originally Posted by asirohi
this did not work, i just want to remove the # marks from the red area, not from the whole file.
# 12  
Old 02-05-2009
Quote:
Originally Posted by vgersh99
once again - reread the OPs requirements:

oops, it would have helped if I had read your entire question Smilie
# 13  
Old 02-06-2009
Thanks guys it worked.Smilie
# 14  
Old 02-06-2009
Tools Explaining my awk solution

Received a message asking me to explain my awk, so I am posting it here for the good of the community.

Code:
> cat play162.sh

awk '
  { if (((NR>=2)&&(NR<=8)) ||
  (NR==17) || (NR==30)) {
    print substr($0,2,99)
  } else {
    print 
  }

}' file162

awk ' ===> starts awk
{ if (((NR>=2)&&(NR<=8)) || ===> checks if line # (>=2 AND <=8) OR
(NR==17) || (NR==30)) { ===> if line # =17 OR line # =30
print substr($0,2,99) ===> if conditions met,
===> print the line beginning @ position 2
} else { ===> if conditions not met
print ===> print the line of text as-is
} ===> end the section within awk

}' file162 ===> end the awk commands, & provide the input file
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Enter carriage return in xml file after each tag (> sign)

I have an xml file which is generated in a single line an looks like this <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?><Batch_Id="1999996" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><some data....><some data....>closing lines...... I need to have a separate line... (3 Replies)
Discussion started by: vx04
3 Replies

2. Shell Programming and Scripting

New to Perl Mail @ sign search and replace in a file

HI I'm terribly new to perl .. I;ve been trying to use this command to search and replace entries in a file I tried this and it works perl -p -i -e 's/old/new/' filename Problem is that I have a list of email addresses and I need to serach and replace the entire email address as my... (5 Replies)
Discussion started by: mnassiri
5 Replies

3. Linux

Linux command to find and replace occurance of more than two equal sign with "==" from XML file.

Please help me, wasted hrs:wall:, to find this soulution:- I need a command that will work on file (xml) and replace multiple occurrence (more than 2 times) Examples 1. '===' 2. '====' 3. '=======' should be replaced by just '==' Note :- single character should be replaced. (=... (13 Replies)
Discussion started by: RedRocks!!
13 Replies

4. Shell Programming and Scripting

Shell not parsing $ sign from file

PFB my shell script which reads a csv file to process it ############################################### fn_java(){ echo JAVA_TOP is $JAVA_TOP echo "cp $filename $filepath/$filename" cp $filename $filepath/$filename } #########################################... (9 Replies)
Discussion started by: Prasannag87
9 Replies

5. Shell Programming and Scripting

how to get data from hex file using SED or AWK based on pattern sign

I have a binary (hex) file I need to parse to get some data which are encoded this way: .* b4 . . . 01 12 .* af .* 83 L1 x1 x2 xL 84 L2 y1 y2 yL By another words there is a stream of hexadecimal bytes (in my example separated by space for better readability). I need to get value stored in... (3 Replies)
Discussion started by: sameucho
3 Replies

6. Shell Programming and Scripting

Type ¥ yen sign in a terminal or a file

I'm trying to enter ¥ yen sign which is a part of a complex password in terminal putty thru bash shell how can i type such character in terminal or even write it in a file as a stdin for the client thanks ---------- Post updated at 05:38 PM ---------- Previous update was at 02:07 PM... (0 Replies)
Discussion started by: h@foorsa.biz
0 Replies

7. Shell Programming and Scripting

Parse file with '=' sign

Hi, Can anyone help me parse the code bellow. I have a file with several lines. I ant to put an 'X' on the lines that ONLY have an '=' in them ignoring comma's, spaces etc.. So: /* , systems.menuLabel.new=New systems.menuLabel.new.mnemonic=N */ Would look like: /* , ... (9 Replies)
Discussion started by: jascas
9 Replies

8. Shell Programming and Scripting

Sign on/Sign off logging script

I'd like to make a script that I can execute every time I sign on to my linux box that keeps track of the time and allows to me to add a remark to a file. So basically once I log in, I run the script, and it outputs the date and time to a text file (log.txt). But that isn't my problem. I need... (1 Reply)
Discussion started by: Glider
1 Replies

9. HP-UX

Replace $ sign within a file using Vi editor

Can someone help me with this command? I want to replace amount fields which are in the format $99.99 to 99.99 in a large data file which is within a HP box. I use Vi editor and tried this command :1,$s//$///g And this does not seem to work Also, I want to replace ^M with spaces in the... (1 Reply)
Discussion started by: dtonse
1 Replies

10. UNIX for Dummies Questions & Answers

remove pound sign from filename

Surpisingly, I've only found information regarding removal of files with special characters in the name. My problem is this: files are downloaded to my Unix box from mainframe, and each one has a pound sign as the first character of the filename. original: #FONT what I need: FONT ... (4 Replies)
Discussion started by: kristy
4 Replies
Login or Register to Ask a Question