---
title: nextflow fs
description: Reference for the nextflow fs command. Perform basic filesystem operations.
---

# `nextflow fs`

Perform basic filesystem operations.

## Usage

```console
$ nextflow fs <subcommand> [args]
```

## Description

The `fs` command performs filesystem operations such as copy, move, delete, and list directory. Like the `file()` method, it works with local files, remote URLs, and remote object storage. Provide storage credentials the same way you provide them when launching a pipeline, through Nextflow config or environment variables.

The source path of each subcommand can be a glob pattern. The subcommand then applies to every matching file.

## Options

##### `-h, -help`

Print the command usage.

## Subcommands

##### `cat <path>`

Print the contents of a file to standard output.

##### `cp <source> <target>`

Copy a file or directory.

##### `ls <path>`

List the contents of a directory.

##### `mv <source> <target>`

Move a file or directory.

##### `rm <path>`

Delete a file or directory.

##### `stat <path>`

<AddedInVersion version="23.10" />

Print the attributes of a file or directory: name, size, whether it is a directory, last modified time, and creation time.

## Examples

List the contents of a remote directory:

```console
$ nextflow fs ls 's3://my-bucket/data/*'
```

Print the contents of a remote file:

```console
$ nextflow fs cat s3://my-bucket/data/file.txt
```

Copy a file to another bucket:

```console
$ nextflow fs cp s3://my-bucket/data/file.txt s3://dest/
```

Copy every file matching a glob pattern:

```console
$ nextflow fs cp 's3://my-bucket/data/*.txt' s3://dest/
```

Move a file:

```console
$ nextflow fs mv s3://my-bucket/data/file.txt s3://my-bucket/archive/file.txt
```

Delete a file:

```console
$ nextflow fs rm s3://my-bucket/archive/file.txt
```

Print the attributes of a file:

```console
$ nextflow fs stat s3://my-bucket/data/file.txt
```
