If first character doesn't equal '#' and same line contains 'temp', print everything else


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting If first character doesn't equal '#' and same line contains 'temp', print everything else
# 1  
Old 12-16-2013
If first character doesn't equal '#' and same line contains 'temp', print everything else

# 2  
Old 12-16-2013
Code:
awk '!(!/^#/&&/temp/)' file

This User Gave Thanks to Yoda For This Post:
# 3  
Old 12-17-2013
A small logical rearrangement of Yoda's Solution, and it sort of reads a little more clearly for me (comment line OR no temp):

Code:
awk '/^#/||!/temp/' fstab

This User Gave Thanks to Chubler_XL For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to print out with equal spacing between columns?

For instance, my file contains the following content... set -A array set -A test ${array}=1 ${array}=2 ${array}=3 ${test}="Boy" ${test}="Girl" ${test}="Dog" x=0 while ;do print "${array}" " " "${test}" x=$((x+1) done... (1 Reply)
Discussion started by: TestKing
1 Replies

2. UNIX for Beginners Questions & Answers

awk or sed to print the character from the previous line after the regexp match

Hi All, I need to print the characters in the previous line just before the regular expression match Please have a look at the input file as attached I need to match the regular expression ^ with the character of the previous like and also the pin numbers and the output file should be like... (6 Replies)
Discussion started by: kshitij
6 Replies

3. UNIX for Dummies Questions & Answers

Cut command doesn't remove (^C) character from only first line

I have a file which has first 2 junk characters(X^C) at beginning of each line in file. When i run cut -c 2- filename it removes junk characters from all lines except on first line it keeps one junk character control C(^C). Not sure why it is not removing only from first line. (2 Replies)
Discussion started by: later_troy
2 Replies

4. Shell Programming and Scripting

Print entire line only if certain fixed character matches the string

Hi All, I have a file testarun.txt contains the below lines and i want to print the lines if the character positions 7-8 matches 01. 201401011111 201401022222 201402013333 201402024444 201403015555 201403026666 201404017777 201404028888 201405019999 201405020000 I am trying the... (4 Replies)
Discussion started by: Arunprasad
4 Replies

5. Programming

Read text from file and print each character in separate line

performing this code to read from file and print each character in separate line works well with ASCII encoded text void preprocess_file (FILE *fp) { int cc; for (;;) { cc = getc (fp); if (cc == EOF) break; printf ("%c\n", cc); } } int main(int... (1 Reply)
Discussion started by: khaled79
1 Replies

6. Shell Programming and Scripting

How to print a particular character n number of times in a line??

hi, Is it possible to print a particular character n number of times in a line? for example. i am print the following line using echo command.. echo "files successfully moved" i want to count the number of characters that are been displayed. i am doin it using echo "files... (8 Replies)
Discussion started by: Little
8 Replies

7. Programming

Print line by character in C

Hello, I am reading the K & R C book, and trying to understand more about putchar()/getchar() by practice. Similar to the exercise 1-12, I want try to parse each line by character. Although there are many site about the exercise, but I could find similar case of mine, which is similar to fold... (11 Replies)
Discussion started by: yifangt
11 Replies

8. Shell Programming and Scripting

awk - setting fs to equal any single character

Hi Does anyone know how to set any character as the field separator with awk/nawk on a solaris 10 box. I have tried using /./ regex but this doesnt work either and im out of ideas. thanks (7 Replies)
Discussion started by: chronics
7 Replies

9. Shell Programming and Scripting

AWK Print Line If Specific Character Is Matched

Hello, I have a file as such: FFFFFFF6C000000 225280 225240 - - rwxs- FFFFFFFF79C00000 3240 3240 - - rwxs- FFFFFFFF7A000000 4096 4096 - - rwxs- FFFFFFFF7A400000 64 64 ... (3 Replies)
Discussion started by: PointyWombat
3 Replies

10. Shell Programming and Scripting

Threshold is less than 0.003 or equal then print the line

Friends, I have very large data files (File1 and File2). Search field1 of File1 into Field1 of File2. If found then do Field1 of File1 MINUS Field1 of File2 if the answer is <= 0.003 (positive or negative) then print that line from File1. File1 ABC1231|1.1111|2.2122|3.3133... (3 Replies)
Discussion started by: ppat7046
3 Replies
Login or Register to Ask a Question