Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8644163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:13:40+00:00 2026-06-12T12:13:40+00:00

in shell ,to make a dir: mkdir /home/test then ,to create a file named

  • 0

in shell ,to make a dir:

mkdir  /home/test

then ,to create a file named “.test” in the “/home/test”

a=list.files(path = "/home/test",include.dirs = FALSE)
a
character(0)
a=list.files(path = "/home/test",include.dirs = TRUE)
a
character(0)
a=list.files(path = "/home/test/",include.dirs = TRUE)
a
character(0)
list.files(path = '/home/test', all.files=TRUE,inclued.dirs=FALSE)
[1] "."     ".."    ".test"
a=list.files(path = '/home/test', all.files=TRUE)
length(a)
[1] 3

how can i get length(a) = 1 using regular expression parameters pattern= in list.files to prune . and ..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:13:41+00:00Added an answer on June 12, 2026 at 12:13 pm

    Use all.files=TRUE to show all file names including hidden files.

    list.files(path = '/home/test', all.files=TRUE)
    

    To answer your edit, one way would be to use a negative number with tail

    tail(list.files(path = '/home/test', all.files=TRUE), -2)
    

    Using only the pattern argument:

    list.files(path='/home/test', all.files=TRUE, pattern="^[^\\.]|\\.[^\\.]")
    

    The pattern says “anything that starts with something other than a dot or anything that starts with a dot followed by anything other than a dot.”


    Although it breaks your requirement to use the pattern argument of list.files, I would actually probably wrap grep around list.statements in this case.

    grep("^\\.*\\.$", list.files(path='/home/test', all.files=TRUE), 
         invert=TRUE, value=TRUE)
    

    The above will find any file names that only contain dots, then return everything else. invert=TRUE means “find the names that do not match”, and value=TRUE means “return the names instead of their location.”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From the command line you can make multiple directories like so: mkdir -p build/linux/{src,test,debug}
In this makefile dirs = $(shell ls) clean: $(foreach dir,$(dirs),echo $(dir);) The output is
I have a custom shell script to make twitter bootstrap from source and then
UPDATE: this is a repost of How to make shell scripts robust to source
I was requested to make a shell script to check for simple mistakes in
I am trying to make an interactive shell script in Perl. The only user
I need something like make i.e. dependencies + executing shell commands where failing command
I have the following Makefile rules: DIR = src SOURCES = $(shell find $(DIR)
I want to create a Makefile (in a parent dir) to call several other
Where should I put the Markdown.pl to make shell could recognize it when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.