We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,620 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

One question about Unix

This is an assignment question, I know i should do it myself, but believe me i have just learned this subject and couldn't find the answer. Please if someone could give me the answer, i would be greatfull. And please if you could hurry because I have to submit on march 3 and only this question is left. Here is the question:

Reduce the number of key strokes to execute this command: tar -t-v-f/dev/fd0

4
Contributors
4
Replies
1 Week
Discussion Span
2 Years Ago
Last Updated
5
Views
sidlampard
Newbie Poster
8 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Hint: most unix utilities accept a compact form multiple flags where you only give a single dash. The tar utility is so old that it doesn't even always require dashes at all.

griswolf
Veteran Poster
1,176 posts since Apr 2010
Reputation Points: 344
Solved Threads: 262
Skill Endorsements: 1

The shortest solution I can think of is

tar tvf/dev/fd0

wulaishiwo
Newbie Poster
10 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

The -t option lists the table of contents, and so the -v (verbose) option could be considered redundant. Just use:

tar tf /dev/fd0
Potion
Newbie Poster
5 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Unrelated (except that it uses tar), here's a nice trick for copying trees while preserving file owner, permissions and date attributes. Every Linux/Unix hack should know this:

$ cd /source_dir
$ tar -cf - * | (cd /target_dir; tar xvf -)

Explanation.
In the source directory we create an archive of all the contents sending the stream to std-out. We then pipe the stream to to a grouped command, which first changes directory, and then extracts the archive from the std-in stream.

Potion
Newbie Poster
5 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0679 seconds using 2.69MB