Skip to content

headFile

Requires a Node.js runtime ('qsu/node')

Returns the first line of the specified text file path. The length argument is the total number of lines to print. Default is 1.

Parameters

NameTypeRequiredDefault
filePathstring
File or directory path
lengthnamednumber1
Number of lines of text to return

named parameters are passed as named parameters in Dart and keyword arguments in Python.

Returns

Promise::string|null

Examples

javascript
await headFile('/home/targets/hello.md', 2); // '# Hello, World!\nSecond line'
dart
await headFile('/home/targets/hello.md', length: 2); // '# Hello, World!\nSecond line'
python
headFile('/home/targets/hello.md', 2) # '# Hello, World!\nSecond line'

Released under the MIT License