ls -l /directory/path | grep -f filter.txt NOT WORKING


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ls -l /directory/path | grep -f filter.txt NOT WORKING
# 8  
Old 05-30-2012
ls -l directory/.

this is the output of the ls -l directory/.

Code:
[localuser@localhost ~]$ ls wiz/.
a2ps.cfg.defs environment.defs ld.so.cache.defs mtools.conf rpc.defs
a2ps-site.cfg.defs ffserver.conf ld.so.conf nanorc.defs rsyslog.conf
adduser.conf fstab.defs legal.defs netscsid.conf screenrc.defs
aliases.defs gai.conf lftp.conf networks.defs securetty.defs
anacrontab.defs gnome-vfs-mime-magic.defs libao.conf nsswitch.conf sensors3.conf
bash.bashrc.defs gram.yafray.defs lintianrc.defs ntp.conf services.defs
bash_completion.defs grep-dctrl.rc.defs locale.alias.defs pam.conf shells.defs
bindresvport.blacklist.defs group-.defs localtime.defs papersize.defs smi.conf
blkid.conf group.defs login.defs.defs passwd-.defs sudoers.defs
blkid.tab.defs hddtemp.db.defs logrotate.conf passwd.defs su-to-rootrc.defs
bogofilter.cf.defs hdparm.conf lsb-base-logging.sh.defs pbuilderrc.defs sysctl.conf
brlapi.key.defs host.conf lsb-release.defs pnm2ppa.conf tidy.conf
ca-certificates.conf hostname.defs ltrace.conf popularity-contest.conf timezone.defs
casper.conf hosts.allow.defs magic.defs preload.conf ts.conf
cowpoke.conf hosts.defs magic.mime.defs profile.defs ucf.conf
crontab.defs hosts.deny.defs mailcap.defs protocols.defs uniconf.conf
crypttab.defs inputrc.defs mailcap.order.defs qemu-ifdown.defs updatedb.conf
cvs-cron.conf insserv.conf mail.rc.defs qemu-ifup wgetrc.defs
cvs-pserver.conf issue.defs manpath.config.defs rarfiles.lst.defs wodim.conf
debconf.conf issue.net.defs mime.types.defs rc.local.defs zsh_command_not_found.defs
debian_version.defs kde4rc.defs mke2fs.conf rearj.cfg.defs
deluser.conf kernel-img.conf modules.defs reportbug.conf
devscripts.conf kerneloops.conf motd request-key.conf
dput.cf.defs ksysguarddrc.defs mtab.defs resolv.conf


Last edited by Scott; 05-30-2012 at 05:11 AM.. Reason: Code tags
# 9  
Old 05-30-2012
You either have to help by a) using code tags; and b) answering with the requested information, or I'm as well to close this thread.
# 10  
Old 05-30-2012
Quote:
Originally Posted by Scott
That's not quite what I asked for Smilie

Code:
cat -v filter.txt

Oh yeah the output result should match all those listed in the filter.txt in the ls -l directory output

for example if I specifically grep a manual string from filter.txt it would display:

Code:
[localuser@localhost ~]$ ls wiz/. | grep timezone.defs
timezone.defs


Last edited by wolf@=NK; 05-30-2012 at 05:13 AM.. Reason: tags
# 11  
Old 05-30-2012
Smilie

And the output of
Code:
cat -v filter.txt

would be?
# 12  
Old 05-30-2012
Data

Code:
[localuser@localhost ~]$ cat -v filter.txt
request-key.conf^M
devscripts.conf^M
kernel-img.conf^M
nsswitch.conf^M
ca-certificates.conf^M
ntp.conf^M
updatedb.conf^M
libao.conf^M
deluser.conf^M
uniconf.conf^M
sysctl.conf^M
mtools.conf^M
preload.conf^M
netscsid.conf^M
mtab.defs^M
passwd.defs^M
sudoers.defs^M
hosts.defs^M
qemu-ifup^M
pbuilderrc.defs^M
profile.defs^M
debian_version.defs^M
networks.defs^M
bindresvport.blacklist.defs^M
lintianrc.defs^M
bash_completion.defs^M
locale.alias.defs^M
dput.cf.defs^M
inputrc.defs^M
protocols.defs^M
a2ps.cfg.defs^M

---------- Post updated at 01:16 AM ---------- Previous update was at 01:16 AM ----------

in this case would this be the cause why egrep or grep -f filter.txt is not working since there is ^M at the end of the filter.txt file?
# 13  
Old 05-30-2012
Woo-hoo an answer Smilie

Quote:
Originally Posted by wolf@=NK
in this case would this be the cause why egrep or grep -f filter.txt is not working since there is ^M at the end of the filter.txt file?
Yes! Remove them from the file and you're good to go.

If you have dos2ux, dos2unix, or whatever it's called, try that, otherwise it's easy in VI too.
# 14  
Old 05-30-2012
I don't see them in ^M (Control M) in vi when I vi filter.txt?

How to remove them? I only see them when I cat -v filter.txt
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

What is the difference ../directory path and ./directory path in ksh?

What is the difference ../directory path and ./directory path in ksh? (1 Reply)
Discussion started by: TestKing
1 Replies

2. UNIX for Beginners Questions & Answers

Convert Relative path to Absolute path, without changing directory to the file location.

Hello, I am creating a file with all the source folders included in my git branch, when i grep for the used source, i found source included as relative path instead of absolute path, how can convert relative path to absolute path without changing directory to that folder and using readlink -f ? ... (4 Replies)
Discussion started by: Sekhar419
4 Replies

3. Shell Programming and Scripting

Help with shell script - filter txt file full of ips

Hello again gentlemen. I would like to make a shell script to 'optimize' a plain text full of IPs. Let's suppose to have this text file: 1.192.63.253-1.192.63.253 1.0.234.46/32 1.1.128.0/17 1.116.0.0/14 1.177.1.157-1.177.1.157 1.23.22.19 1.192.61.0-1.192.61.99 8.6.6.6 I want to... (2 Replies)
Discussion started by: accolito
2 Replies

4. UNIX and Linux Applications

Ssmtp -t < /path/to/the/message.txt (How to format message.txt for html email)

ssmtp has been running well under Kubuntu 12.04.1 for plain text messages. I would like to send html messages with ssmtp -t < /path/to/the/message.txt, but I cannot seem to get the message.txt file properly formatted. I have tried various charsets, Content-Transfer-Encoding, rearranging the... (0 Replies)
Discussion started by: Ronald B
0 Replies

5. Shell Programming and Scripting

Filter specified path

We have 10 jobs entry in crontab like this 0 7 * * 0 && (source /x/y/z .bashrc ; /x/y/z /test.sh Table1 /ABC/TEST >x/y/z/log (every job have different o/p Path) can any one help me to filter only the output PATH /ABC/TEST from the file dup_cron. (1 Reply)
Discussion started by: netdbaind
1 Replies

6. Shell Programming and Scripting

"find . -printf" without prepended "." path? Getting path to current working directory?

If I enter (simplified): find . -printf "%p\n" then all files in the output are prepended by a "." like ./local/share/test23.log How can achieve that a.) the leading "./" is omitted and/or b.) the full path to the current directory is inserted (enclosed by brackets and a blank)... (1 Reply)
Discussion started by: pstein
1 Replies

7. UNIX for Dummies Questions & Answers

Present Working Directory (not the full path)

Hi, Is there a command that tells you right away the current working directory? I know the command "pwd", but that one gives the full path. if pwd gives me: /a/b/c/d/ggg/HERE I want something that will give me: HERE Thanks, Gaurab (13 Replies)
Discussion started by: gaurab
13 Replies

8. Shell Programming and Scripting

sed to read x.txt and grep from y.txt

How would I write a command(s) to read from a file (list) that looks like this: 29847374384 and grep from a second file (list) that looks like this: 29847374384, jkdfkjdf,3833,ddd:confused: (1 Reply)
Discussion started by: smellylizzard
1 Replies

9. Shell Programming and Scripting

how do I filter double lines from a txt file

Hi, I have a file with the following: access-list.txt router1 access-list 1 permit any any access-list 1 deny any any router2 access-list 2 permit any any access-list 2 deny any any router3 access-list 3 permit any any access-list 3 deny any any I want to hava an output that... (10 Replies)
Discussion started by: I-1
10 Replies

10. Shell Programming and Scripting

need help--script to filter specific lines from multiple txt files

Hi folks, - I have 800 txt files - those files are cisco router configs router1.txt router2.txt ... router800.txt I want to accomplish the following: - I want to have a seperate file with all the filenames that I want to process - I want a script that goes trough all those... (7 Replies)
Discussion started by: I-1
7 Replies
Login or Register to Ask a Question