Write a command sequence to find all the files modified in less than 2 days and print the record count of each.



Write a command sequence to find all the files modified in less than 2 days and print the record cou..

Answer / Tara Singh Meena

To find all the files modified within the last 2 days and print the record count of each, you can use a combination of `find`, `ls`, and `wc` commands. Here is a command sequence that achieves this:n```nfind /path/to/directory -type f -mtime 01 -exec ls -l {} ; | awk '{print $5, $NF}' | sort | uniq -cn`` This command first finds all files modified in the last two days (-mtime 01) within the specified directory (/path/to/directory). It then pipes this output to `ls -l` to get detailed file information. The `{}` is replaced by the current file being processed by the find command. The pipe (|) is used to pass the output of one command as input to another command. The output is then piped to `awk` to extract the number of links and the filename, sorted, and unique records are counted using `sort` and `uniq -c`, respectively.n

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Shell Script Interview Questions

What is awk in shell scripting?

1 Answers  


What is a shell in operating system?

1 Answers  


is this growing field and what is average package in this?

1 Answers  


madhar chod unix ke 10 commands dhang se likh nahi sakta hai

1 Answers   Cap Gemini,


Hi, all Scripting professional. Q. I have written script1.sh and calling script2.sh in script1.sh file using bash shell as interpreter and my log in shell also bash shell.My code like Script1 #!/bin/bash echo "My script2 call" . script2.sh Here script2.sh file run successfully but when I have changed my interpreter bash to ksh like #!/bin/ksh Error are comming script2.sh command not found. Guid me how to call other script in our main script.

2 Answers  


What is awk in shell script?

1 Answers  


Is shell scripting easy to learn?

1 Answers  


write a shell script to check whether all the directories in the path exist has read and write permission

1 Answers  


Why is used in shell scripting?

1 Answers  


Which shell is the best?

1 Answers  


What does egrep mean?

1 Answers  


The information of the two files should be redirect to Third file in such a way that, the third file contain the information like this. 1st line in third file should be from 1st file 2nd line in Third file should be from 2nd file 3rd line in Third file should be from 1st file 4th line in Third file should be from 2nd file - - so on

2 Answers   Caritor,


Categories