-3

How do I list all files and directories in the /etc/ directory, which have one or more digits in its file-name, and save the output to a file, in the home directory.

The output must have the full path (eg. /etc/filename). I've tried to do it using the ls command, but failed to do so. Also while using the find command I didn't succeed.

  • 1
    What did you try and what was the result ? – Jeff Schaller Nov 19 '18 at 10:58
  • There are two questions in here. “How do I list all files and directories in the /etc/ directory, which have one or more digits in its file-name, and save the output to a file, in the home directory.” Please one question per question. – ctrl-alt-delor Nov 19 '18 at 12:52
3

You can use several ways:

ls -lR /etc >~/file
find /etc >~/file

Check the outputs and select the desired

Based on your edited question you can use command like:

find /etc |grep -E '[0-9]'
  • I'm sorry I have just edited my question. I want to list all files and directories in the /etc/ directory which have one or more numbers in its' file name – Amr A. EL-Amrawy Nov 19 '18 at 10:17
  • @AmrA.EL-Amrawy, check my edited answer – Romeo Ninov Nov 19 '18 at 10:22
  • Thank you, Romeo. Is there a way to use ls instead of find here? – Amr A. EL-Amrawy Nov 19 '18 at 10:25
  • @AmrA.EL-Amrawy, I do not know the way to make ls to show path and filename in one line. The samples is IMO with find – Romeo Ninov Nov 19 '18 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.