Go Back   The UNIX and Linux Forums > Homework and Emergencies > Homework & Coursework Questions


Homework & Coursework Questions Students must use and complete the template provided. If you don't, your post may be deleted! Special homework rules apply here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 05-13-2012
Registered User
 
Join Date: Mar 2012
Posts: 15
Thanks: 2
Thanked 0 Times in 0 Posts
Produces the application specified command to all regular files in a given directory

1. The problem statement, all variables and given/known data:

write a script in language shell bash, which produces the application specified command to all regular files in a given directory (and all subdirectories)

Input parameters:

- Defined directory;

- Given command.


2. Relevant commands, code, scripts, algorithms:



3. The attempts at a solution (include all code and scripts):
this is my solution, but i'm not sure that it's true?


Code:
#!/bin/bash
echo ' '

if [ "$1" = "" ]
  then echo 'insert your directory, please'
else 
  if [ "$2" = "" ] 
     then echo 'insert your command, please'
  else
     find $1 -type f | xargs $2
  fi
fi

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Hanoi university, Hanoi, VietNam

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
Sponsored Links
    #2  
Old 05-13-2012
DukeNuke2's Avatar
Soulman
 
Join Date: Jul 2006
Location: Berlin, Germany
Posts: 5,112
Thanks: 43
Thanked 194 Times in 189 Posts
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Hanoi university, Hanoi, VietNam

there is information missing!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Produces the application specified command to all regular files in a given directory numeracy Shell Programming and Scripting 1 05-13-2012 05:42 AM
linux sort command produces strange output ajb UNIX for Dummies Questions & Answers 3 08-11-2011 12:17 PM
Apply 'awk' to all files in a directory or individual files from a command line ScKaSx Shell Programming and Scripting 4 11-04-2010 06:50 PM
How to apply a regular expression in all the files in a directory Lucky Ali Shell Programming and Scripting 2 11-01-2009 04:24 PM
Command to view files in Directory VamsiVasili Shell Programming and Scripting 4 09-23-2009 05:34 PM



All times are GMT -4. The time now is 02:03 PM.