Exclude variable from a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Exclude variable from a file
# 8  
Old 09-15-2016
Can I add a word of caution that the lines in your exclude file will match anywhere on the line in your input file. If you need to ensure that it is (for example) only lines starting with abc then your exclusion file should be written as ^abc

So, for the input file:-
Code:
abc123
def456
123abc
456def
The end

... and the exclusion file:-
Code:
abc

you would get just:-
Code:
def456
456def
The end

If you exclusion file is
Code:
^abc

... then the output would be:-
Code:
123abc
def456
456def
The end

If you want to exclude lines with the listed patterns in other specific places then there are usually ways to do that too.

I hope that this helps avoid a problem (if it even exists)
Robin
This User Gave Thanks to rbatte1 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

Find and exclude what is in file

Hello everyone, I try to find folders older than 3 years and display them, but excluding some directories, the below code does NOT exclude listed directories: find . -maxdepth 3 -mtime +1095 -type d -exec ls -l {} \; | grep -vFf oldExclude >> older oldExclude Folder1/ Folder2/... (7 Replies)
Discussion started by: Abu Rayane
7 Replies

2. UNIX for Dummies Questions & Answers

Exclude txt file in rsync

Hi Folks, I'm using rsync on Solaris 10 to backup a web server and need to exclude the cache and tmp directories. The man pages and google on rsync --exclude are ambiguous but I have tried--exclude=".*" and --exclude/remote_server/absolute_path with success only on the tmp files. Rather than make... (2 Replies)
Discussion started by: SmokeyJoe
2 Replies

3. UNIX for Dummies Questions & Answers

Reading file and exclude in ksh

I have a text file containing some file names. And I've a directory containing files with different name. I want to do some operaration (deleting) on the files which are NOT listed on the text file. Im using KSH. PLEASE HELP !!!!! Urgent Help!!!!! (2 Replies)
Discussion started by: maheshbabu
2 Replies

4. UNIX for Dummies Questions & Answers

Exclude file with tar

hi, i am trying to use a exclude file to exclude some file directories while making a tar archive. This is my command: tar -pcvf orahome10gR2.tar.gz db_1 -X /home/oracle/excludeFile.txt /home/oracle/ when i execute it, it seem to be tar-ing. But once is done, i cd to /home/oracle and could... (2 Replies)
Discussion started by: redologger
2 Replies

5. Shell Programming and Scripting

Exclude a file or not in

Hi Gurus. I have a directory and i receive many files with extension .log. I processed the file as i get it. i want to process all the files except one which i know i don't want to process. cd /backup/temp/rajesh/PACS #--- directory , under this i have below files... (1 Reply)
Discussion started by: guddu_12
1 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

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

8. Shell Programming and Scripting

ls to exclude file

I have cgicsave.env and cgic*, but I want to print cgic* value but NOT cgicsave.env Thanks (9 Replies)
Discussion started by: xs2punit
9 Replies

9. Shell Programming and Scripting

How to exclude certain colomn from the file?

Hi I have a file in the following format: 4135 f4135acc: 39798 rmtdb: 0 /t1/data/f4135acc.dta 4135 f4135pdb: 39795 rmtdb: 0 /bb/data/f4135pdb.dta 4135 p4135eng: 0 rmtdb: 0 /bb/bin/p4135eng 4135 r4135eng: 14142 rmtdb: 0 ... (6 Replies)
Discussion started by: aoussenko
6 Replies

10. UNIX for Dummies Questions & Answers

How to exclude a record from unix file

I want to exclude records from my unix file that have a specific pattern. How can I do this? Thanks. Ryan (1 Reply)
Discussion started by: Ryan2786
1 Replies
Login or Register to Ask a Question