LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-31-2011, 09:36 AM   #1
wjtaylor
Member
 
Registered: Feb 2009
Posts: 78

Rep: Reputation: 15
Can I dereference a wildcard in a command?


Can I dereference a wildcard in a command?

For example if I want to create a file with the md5 hashes of compressed versions of files in a directory...

gzip -rc ./source/* | md5sum -b - >> hash.txt

This above command gives me a file with one hash for the filename *

I would like to get a file with the hashes and filenames for every file gzip compresses.

Do I have to script a foreach routine for this?

Thanks,
WT

Last edited by wjtaylor; 03-31-2011 at 10:08 AM.
 
Old 03-31-2011, 10:19 AM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
I don't quite understand what your command is, but the code
snippet below cycles thru all your files gzips each file and
calculates the md5sum. Filename and md5sum are written to a file.

Code:
for fn in $(ls ./source/*)
do
  gzip $fn
  echo -e $fn >> myfile
  md5sum $fn.gz >> myfile
done
jlinkels
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using the CHOWN command with a wildcard. Skillz Linux - General 14 01-25-2010 09:42 AM
Find command to search wildcard in path? markdjones82 Linux - General 12 12-11-2009 01:02 AM
[SOLVED] ls -d --dereference-command-line-symlink-to-dir does not work as advertised jgombos Linux - General 2 09-03-2009 07:18 AM
pointer dereference problem cranium2004 Programming 4 05-03-2005 09:34 AM
script for a command that won't accept wildcard value hemp4fuel Programming 4 05-24-2004 05:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration