ID
nuxdnn3bcsa7f6pfoggs7go7wy
Status
Succeeded
Source
Web
Hardware
A100 (80GB)
Total duration
Created
Webhook

Input

prompt
In Bash, how do I list all text files in the current directory (excluding subdirectories) that have been modified in the last month?
system_prompt
Empty string
max_tokens
500
temperature
0.8
top_p
0.95
top_k
10
frequency_penalty
0
presence_penalty
0
repeat_penalty
1.1

Output

📂 To list all text files (.txt extension) in the current directory (excluding subdirectories) that have been modified in the last month, you can use a combination of `find` and `ls`:

```bash
ls -1t $(find . -type f -name "*.txt" -mtime -30d | sort)
```

🔧 Here's how it works:

* `find . -type f -name "*.txt"`: Finds all text files in the current directory (excluding subdirectories). `-type f` means regular file. `-name "*.txt"` means files with a `.txt` extension.
* `-mtime -30d`: Specifies that we're interested only in those text files that have been modified within the last 30 days. The `find` command accepts a range, so `-30d` is interpreted as "less than or equal to 30 days".
* `$( )` : Captures the output of the `find` command and uses it as an input for the `ls -1t` command.
* `ls -1t`: Lists files in a single column (`-1`) sorted by modification time (`-t`). The result will be a list of text files, sorted with the most recently modified first.

This approach relies on `find` to search and filter for relevant files based on criteria like file type, name, and modification date. Then, it passes those results through `sort` before feeding them to `ls -1t`, which displays the list of files in a single column sorted by their modification time (newest first).

**Note:** If you're using MacOS or Linux with GNU findutils installed, you can use `-mtime +30d` instead of `-mtime -30d`. This is because on these platforms, the meaning of `-30d` is "more than 30 days". Source: assistant
Generated in