Produces the application specified command to all regular files in a given directory

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Produces the application specified command to all regular files in a given directory
# 1  
Old 05-13-2012
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).
# 2  
Old 05-13-2012
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!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command to delete half of files in directory.

Hello Friends, I have directory called /tmp. which stores the log files. Whenever it becomes full, i want to delete half of files from all log files. even after deleting the files, if space is more than 90% then it should delete rest of half files. While deleting files, older files... (7 Replies)
Discussion started by: Nakul_sh
7 Replies

2. UNIX for Dummies Questions & Answers

Read all files in a directory for a unix command

Hello, Below, I have a unix command, which can be executable for single file. cat input.txt | sort -k3,3 > output.txt I have 100 input files in a directory. It is hectic and time taking to run the above command for all the 100 files for 100 times. Now, I want to execute the above unix... (2 Replies)
Discussion started by: koneru_18
2 Replies

3. Shell Programming and Scripting

How to get the list regular files in a given directory?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 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... (3 Replies)
Discussion started by: numeracy
3 Replies

4. Shell Programming and Scripting

Produces the application specified command to all regular files in a given directory

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. this is my answer, but i'm not sure that it's true? #!/bin/bash echo '... (1 Reply)
Discussion started by: numeracy
1 Replies

5. UNIX for Dummies Questions & Answers

linux sort command produces strange output

cat a .a ba .b bb .c bc sort a .a .b ba bb bc .c NOTE: .a and .b appears before ba and bb, where as .c appears after bc. In general (3 Replies)
Discussion started by: ajb
3 Replies

6. Shell Programming and Scripting

Apply 'awk' to all files in a directory or individual files from a command line

Hi All, I am using the awk command to replace ',' by '\t' (tabs) in a csv file. I would like to apply this to all .csv files in a directory and create .txt files with the tabs. How would I do this in a script? I have the following script called "csvtabs": awk 'BEGIN { FS... (4 Replies)
Discussion started by: ScKaSx
4 Replies

7. Shell Programming and Scripting

How to apply a regular expression in all the files in a directory

I have say 100 text files (with .txt extension) in a directory. An example of the content in the file is given below "NAME" "cgd1_200" "cgd1_3210" "cgd1_560" "cgd2_2760" "cgd2_290" "cgd3_3210" "cgd3_3310" "cgd3_660" "cgd5_2130" "cgd5_4080" "cgd6_3690" "cgd6_4480" "cgd8_1540"... (2 Replies)
Discussion started by: Lucky Ali
2 Replies

8. Shell Programming and Scripting

Command to view files in Directory

Hi, Can u provide me the command to view files in a directory.Urgent Pls. -Vamsi (4 Replies)
Discussion started by: VamsiVasili
4 Replies

9. Shell Programming and Scripting

Command to view files in Directory

Hi, Can you help me in providing me a command to view all files present in a directory. Thanks a lot. -Vamsi (1 Reply)
Discussion started by: VamsiVasili
1 Replies

10. UNIX for Dummies Questions & Answers

can we list other than c files in a directory with only 'ls' command?

Guys, can anybody help me in the following........ I have different types(c files,ordinary text files etc) in a directory. is there any way to list other than .c files using the 'ls' command only. i tried with the following. ls *.*. its not listing the .c files,but at the same time not... (3 Replies)
Discussion started by: venkat
3 Replies
Login or Register to Ask a Question