shell


find and grep command this but not that


I am trying to find all the files which are not the *.o (object) files and store in file MyFile.lst in the current directory Tree.
I am doing it from using below command.
#! /usr/bin/ksh
find . -type f | grep -v "*.o" >> MyFile.lst
For some reason it is not working please help me.
Edit:
find . -type f | grep -v '\.o$' >> MyFile.lst
Seems like working. Any comment/ suggestion.(added keith.layne correction)
You don't need grep.
find . -type f '!' -name '*.o' >> MyFile.lst
In grep, the searching pattern should be a regular expression. Therefore, ., $ and * are having special meaning.
. means match any character
$ means match the end of a line
X* means match X, zero or more times(greedy)
grep -v '\.o$' would match files with .o extension. (You need to escape . for its literal meaning).
Your edit should be fine...$ (as I'm sure you know) should match the end of the line.
You should make one change, however: escape the . (a wildcard) with a \. Otherwise you'll match for example a file named 'Mo'.
I think (from a quick test) that grep treats * as a literal at the beginning of a pattern.
Your script will now be:
#! /usr/bin/ksh
find . -type f | grep -v '\.o$' >> MyFile.lst
find . -not -name "*.o" -type f >> list

Related Links

Adjust PDF canvas maximum page size
Convert date and time to seconds
Oozie shell action doesn't send mail notification
How to get the impala query output log into a variable using unix shell script?
teradata table error using multiload script
awk command to print multiple columns using for loop
Bash Script for loop?
why one bteq script works, but not the other
CoovaChilli redirect to a new page on successfull login, to display user account balance
First and last days of month given a specific day of that month - shell
wget downloads files from FTP site TWICE
Ignore input_userauth_banner when running ssh-copy-id
What does >& means in the following code snippet
shell script “syntax error: `done' unexpected.”
shell script compare numbers return illegal number
Read file, pick field values and make it tab delimited

Categories

HOME
django
google-cloud-platform
gdb
merge
depth
xbee
cq5
vxml
zip
drop-down-menu
reactive-programming
endeca
fhir
mel
appcelerator-studio
why3
emoji
line
do-while
capistrano3
google-data-studio
googlebot
ember-cli
dataflow-diagram
parcelable
php-mysqlidb
tosca
firebase-analytics
angular-translate
datastax-enterprise-graph
iis-express
gitlab-api
complex-numbers
dumpbin
fstream
rselenium
hreflang
vue-chartjs
sharding
baidu-map
openproject
cd
release
recurrent-neural-network
loading
cin
p4merge
parser-generator
dbnull
oracle-service-bus
congestion-control
android-checkbox
lampp
sonarlint-eclipse
dotnet-httpclient
podscms
page-replacement
libjpeg
janus
rocks
simplepie
pacemaker
latin
preprocessor
dotnetnuke-7
dup
expectations
lua-telegram-bot
nullable
false-sharing
phpgrid
sapi
xenomai
computer-architecture
lasso
rdflib
kubuntu
android-broadcast
code-documentation
formview
machine-instruction
named-parameters
ignite-ui
lambda-architecture
cancellation
gwt-openlayers
modular
cffile
process-explorer
css-reset
dolby-audio-api
mantle
chart-director
os.system
pyunit
rmiregistry
apache-commons-dbutils
relative
creole
socketserver
wcf-instancing
complex-event-processing

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App