exclude a line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting exclude a line
# 1  
Old 04-24-2008
exclude a line

Hi,
thanks for your help. I wrote this script :
Code:
# ! /bin/sh
file=snapshot.txt
cat $file | while read line ;
do
{
myvariable=`grep "Nombre de ROLLBACK internes" |sed 's/.*.=//'`
echo $myvariable
}
done

It looks in a file "snapshot.txt" for the lines containing "Nombre de ROLLBACK internes". But there are two lines containing this :
Nombre de ROLLBACK internes = 0
Nombre de ROLLBACK internes dus à interblocages = 7

How can I exclude the following line :
Nombre de ROLLBACK internes dus à interblocages = 7


This my snapshot.txt file :
Code:
Num. de partition de base de données du catalogue       = 0
Nom du catalogue du noeud réseau                        =
Syst. d'exploitation serveur de base de données         = NT
Nombre de ROLLBACK internes = 0
Nombre de ROLLBACK internes dus à interblocages = 7
Emplacement de la base de données                       = Local
Horodatage de la première connexion à la base     = 18.04.2008 05:31:56.832765

Regards.
# 2  
Old 04-24-2008
one way
Code:
myvariable=`grep "Nombre de ROLLBACK internes" | grep -v "dus à interblocages" | sed 's/.*.=//'`

# 3  
Old 04-24-2008
Some possibilties:

Code:
grep 'Nombre de ROLLBACK internes =' snapshot.txt |cut -d" " -f6

awk '/^Nombre de ROLLBACK internes =/{print $6}' snapshot.txt

sed '/^Nombre de ROLLBACK internes = /s/.*= //' snapshot.txt

Regards
# 4  
Old 04-24-2008
thank you.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Exclude First Line when awk

Hi there, Where do I add the !NR==1 into the awk statement such that it ignores the first line . awk '/1.2 Install/ {P=0} /1.1 Apply/ {P=1} P {print FILENAME, $0} ' solarisappsummary.txt solarisdbsummary.txt solaris_websummary.txt (12 Replies)
Discussion started by: alvinoo
12 Replies

2. Shell Programming and Scripting

Exclude string

I would like to write a script to check the log , if any line in the log have the string in include_list.txt but do not have the string in exclude_list.txt , then send alert mail to administrator , as below example , the line 1 have the string "string 4" ( which is in include_list.txt ) but do not... (7 Replies)
Discussion started by: ust3
7 Replies

3. Shell Programming and Scripting

Exclude files in ls

Hi, I need to exlucde the files which are present in exclude.txt from a directory exlcude.txt AUZ.txt AUZ.chk NZ.txt NZ.chk tried with below code but not working ls -ltr | grep -v `cat exclude.lst` (9 Replies)
Discussion started by: rohit_shinez
9 Replies

4. UNIX for Dummies Questions & Answers

Exclude new line character while searching

Hi, I have a log file and want to search "0.48976360737438795" with excluding new line character. Currently i am using the following command: cat LogFile.log | tr -d '\n' | grep '0.48976360737438795' This command giving me the response if file size is small but if i am using a big file... (11 Replies)
Discussion started by: ankit jain
11 Replies

5. Shell Programming and Scripting

exclude blank line

hi, how can i exclude blank line along with #, in the below command. crontab -l|grep -v "^#" |wc -l thx (3 Replies)
Discussion started by: bang_dba
3 Replies

6. Ubuntu

[Solved] Using Find with an exclude/exclude file

I am familiar with using tar and exclude/include files: tar zcf backup.dirs.tgz --files-from=include.mydirs --exclude-from=exclude.mydirs --no-recursion but was wondering if I could use find in the same way. I know that you can just specify the directories to exclude but my list is... (2 Replies)
Discussion started by: metallica1973
2 Replies

7. Shell Programming and Scripting

Perl exclude directories in command line

Hi, I use find command to list all the files in a directory and its sub-directories, but the problem is to exclude certain directories during search. Can i give the directory names in command line to skip them and search rest of the directories? For example i have directories: test ../test1... (1 Reply)
Discussion started by: nmattam
1 Replies

8. Shell Programming and Scripting

Have to exclude the first and last line of the file : help me

hi , i am very new to perl . scriptting.. pllease can any one help me ...pleaseeeeeee i ll have a file which look likes 123 |something |567 456 |welcome |789 457 |inboxpost |790 . . 123 |something |567 i have to execute all the lines in the file except the first and the... (14 Replies)
Discussion started by: vishwakar
14 Replies

9. UNIX for Dummies Questions & Answers

exclude columns with a matching line pattern

Hi , I have 5 columns total and am wanting to search lines in columns 3-5 and basically grep -v patterns that match 'BBB_0123' 'BVG_0895' 'BSD_0987' Does anyone know how to do this? I tried combining grep -v with grep -e but, it didn't work. Thanks! (5 Replies)
Discussion started by: greptastic
5 Replies

10. UNIX for Dummies Questions & Answers

Getting 'tar' to exclude

I want 'tar' to exclude certain dir's. tar cvf ............. ............ does the whole lot, but I want to exclude the 'log' dirs. (6 Replies)
Discussion started by: kuultak
6 Replies
Login or Register to Ask a Question