parse a file for a special character


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting parse a file for a special character
# 8  
Old 10-09-2008
What if there are multiple /usr/bin/whatever lines?
# 9  
Old 10-09-2008
Quote:
Originally Posted by era
What if there are multiple /usr/bin/whatever lines?
The awk line will find all of them. It starts at the top of the file, finds each line containing the string "/usr/bin/whatever" (without quotes), and for each one found, it evaluates whether it has # in front. Multiple lines aren't a problem.
# 10  
Old 10-10-2008
Hi all again

On a Solaris machine:

#awk '$0 ~ /\/usr/bin\/whatever/ { if ( match($0, "^#") ) { print "line is commented" } else { print "line is not commented" } }' filename

awk: syntax error near line 1
awk: bailing out near line 1


On a Redhat machine:

awk '$0 ~ /\/usr/bin\/whatever/ { if ( match($0, "^#") ) { print "line is commented" } else { print "line is not commented" } }' filename
awk: cmd. line:1: $0 ~ /\/usr/sbin\/whatever/ { if ( match($0, "^#") ) { print "line is commented" } else { print "line is not commented" } }
awk: cmd. line:1: ^ backslash not last character on line


any idea?

thank you,
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Red Hat

Special character ^@ in CSV file

All, I am having a tough time with Linux and CSV file. My CSV file gets generated from Cognos on Linux machine that contains special characters. At first instance when I do vi <filename> to that file, I can't see anything. I did tail -2 and redirected to another temp file and did vi <filename>,... (2 Replies)
Discussion started by: donadarsh
2 Replies

2. Programming

Problem with control file and special character

I am getting error when loading data file using ctl file. I get this error only when there is special character. Below is some data. DataFile=> company_id|ciu_id|english_name|iso_country_code|active|partner_name 1-2JT-122||Expert Järvenpää|FI|A|Expert Järvenpää Control File=> LOAD DATA... (1 Reply)
Discussion started by: rshivarkar
1 Replies

3. Shell Programming and Scripting

Remove special character ($) from file names

Hello I've searched here and on the 'net for examples of a script or command line function that will remove the $ character from all file names only that can be done within the directory that contains the file names - which are all html files. ie, I have a directory that contains html files... (6 Replies)
Discussion started by: competitions
6 Replies

4. Shell Programming and Scripting

Removing Special Character from File.

Hi, My file has this special character "^M" I would like to remove this characters. eg: abc,abc,^M i tried using sed but doesnt work. i used octal dump command to see special character it returns following: 015 \r Appreciate your reply. (6 Replies)
Discussion started by: pinnacle
6 Replies

5. Shell Programming and Scripting

parse special character in the line

Hi all, I have a file with some module names as below. Font::AFM Data::Grove ---> libxml-perl Net::LDAP ---> perl-ldap DBI XML .... ... .... and so on ... The file has some lines with the character " -->" . Now how can I cut only the last column of the line wherever "-->" is... (4 Replies)
Discussion started by: vijaya2006
4 Replies

6. UNIX for Dummies Questions & Answers

Special character in my file

I have a special character in my file. It displays as a '#' sign but when I do this command I do not find the line. fgrep 'G#ant' file1 I want to replace the special character with another value but I need to know what character it really is. Any ideas on how to replace this '#' value with... (3 Replies)
Discussion started by: Ryan2786
3 Replies

7. Shell Programming and Scripting

delete a special character in file

hi i want to delete a particular character in file. example file name:abcsample abc=bbbqw3/ hidh=ajjqiwio4/ xyx=hakjp/ ........../ ......./ i want to delete that special character (/) in abcsample file Permnently.please give the required commands for my requirement. required... (1 Reply)
Discussion started by: srivsn
1 Replies

8. Shell Programming and Scripting

delete a special character in file

hi i want to delete a particular character in file. example file name:abcsample abc=bbbqw3/ hidh=ajjqiwio4/ xyx=hakjp/ ........../ ......./ i want to delete that special character (/) in abcsample file.please give the required commands for my requirement. thank you (3 Replies)
Discussion started by: srivsn
3 Replies

9. Solaris

Mount a character special file

Hi together I have 2 systems, mars and venus. The configuration is the same. Every system has a SDLT. I will now backup the datas from mars on the tapedevice from venus. I have shareed the tapedevice (venus) and mounted on mars. Now my problem: when I write on the mountet tapedevice, the... (1 Reply)
Discussion started by: MuellerUrs
1 Replies
Login or Register to Ask a Question