06-05-2010
ABC.txt has 2400 lines in total and out of that 200 line of some pattern that needs to be commented. rest of the lines should be untouched.
For the lines to be commented pattern, i have got those in a temp file to use it as an identified key.
---------- Post updated at 08:40 PM ---------- Previous update was at 08:36 PM ----------
I am facing hard luck in the previous solution as well. The command runs but not commenting enteries.
sed -e 's/\(^FIM$\)/#\1/g' /tmp/abc
san% grep FIM /tmp/abc
FIM1
FIM2
FIMR45
---------- Post updated at 08:54 PM ---------- Previous update was at 08:40 PM ----------
Got the quick workaround to enjoy my weekend
perl -p -i -e "s/PM/#PM/g" ABC.TXT
Last edited by sdosanjh; 06-07-2010 at 02:43 AM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello folks
Hope all are fine, I have query need suggestion, if these lines two lines are already commeted no need to do anything, one more thing order of alpha, gama may be different.
I have a two lines in a file data.txt
%checksum
alpha gama beta penta hexa
I want to do... (8 Replies)
Discussion started by: learnbash
8 Replies
2. Shell Programming and Scripting
I want to remove the commented lines in a file identified by ' symbol at the start of each ine. A sample example will be like:
Input
-----
'IFerr_flag=0THEN
iferr_flag=0then
iferr_flag=0then
iferr_flag=0then
iferr_flag=0then
iferr_flag=0then
iferr_flag=0then
Output
-------... (3 Replies)
Discussion started by: joyan321
3 Replies
3. Red Hat
Hi all,
is it possible to add a comment starting with "#" (with vi for example) to the static route file in:
/etc/sysconfig/network-scripts/route*
Are you aware of any problems this can cause after a network restart?
Thanks,
Evan (1 Reply)
Discussion started by: Evan
1 Replies
4. Shell Programming and Scripting
I have 2 files: fileA and fileB.
content of fileA
---------------
admin.teacher is in new york;
admin.mason is in new york;
admin.driver is in new york city;
user.trucker is in hartford;
admin.developer is in new york state;
content of fileB
----------------
admin.teacher is in... (2 Replies)
Discussion started by: lowprofile
2 Replies
5. Shell Programming and Scripting
Hello,
Be indulgent for my english.
Can you help me ?
function f1 {
}
egrep -v '^#' list_file \
| while read arg1 arg2 arg3 arg4; do
f1 $arg1 $arg2 $arg3 $arg4
done
In list_file there is
I want to replace list_file by a $var
then when i launch the script with a file's... (13 Replies)
Discussion started by: amazigh42
13 Replies
6. UNIX for Dummies Questions & Answers
Legends,
Can you please help me in following.
I need to comment lines from “/tmp/a.txt” from the line A to line B through the command prompt only.
Please use variables not direct values like 2 or 5
It can be done with VI editor but it's not matches with my requirement (: 2,5 s/^/#/g).
... (1 Reply)
Discussion started by: sdosanjh
1 Replies
7. Shell Programming and Scripting
Platform : RHEL 5.4
I have several .sql files in a directory. I want to comment lines 10 to 25 for all .sql files.
How can I do this ?
The symbol for comment in SQL is --
eg:
-- select salary from emp where empname = 'URS' ; (3 Replies)
Discussion started by: omega3
3 Replies
8. Shell Programming and Scripting
hi!
I want to comment and uncomment 2 lines in my config files that goes like:
CONTACT_LIST="abc@xyz.com;"
#CONTACT_LIST="def@xyz.com;"
I want to sawp the commnets in above lines and desired output should be:
#CONTACT_LIST="abc@xyz.com;"
CONTACT_LIST="def@xyz.com;"
Please suggest. (1 Reply)
Discussion started by: scriptNovice
1 Replies
9. Shell Programming and Scripting
Hi,
I need to comment out (insert # in the front of a line) a line that has entry Defaults requiretty using command-line as I need to do this on hundreds of servers.
From
Defaults requiretty
To
#Defaults requiretty
I tried something like below but no luck: Please advise,... (3 Replies)
Discussion started by: prvnrk
3 Replies
10. Shell Programming and Scripting
Dear Gurus,
I have a file which comes every day with set of data, as a part of processing i want to add a comment at the start of every line.
e.g of file
<PCL>
2E;"HCA";"COP Car A";"ODBS_CFG"
7C;"DD";"Doors Car D";"ODBS_CFG"
3D;"XA";"Auxiliary Car A";"ODBS_CFG"
3E;"XB";"Auxiliary... (12 Replies)
Discussion started by: guddu_12
12 Replies