Questions tagged [file-system]
For challenges relating to manipulating and traversing the file system. This may include reading directory trees, creating, moving and deleting files or directories, reading or changing file permissions, etc.
55 questions
1
vote
2
answers
224
views
List directories needed to exist to reach a path ("mkdir -p --dry-run")
Given a path to a directory, print a list of directories that need to exist in order to reach the directory specified in the path. Include the final pathname component, if applicable.
This challenge ...
17
votes
11
answers
1k
views
Directory traversal attack detection
Given a path to a file or a directory, detect whether the path can traverse to outside the current working directory, or attempt to traverse to the "parent directory" of the root directory.
...
-10
votes
1
answer
571
views
Bingo Cards PDF
Write code to generate a PDF file containing 6 bingo cards. Winner is the one that uses the shortest code and needs no actions except for installing a library and running the code. (No Save As PDF). ...
8
votes
2
answers
237
views
Filetype Color Codes
On Unix-like systems, the ls command lists files. GNU's version of ls also colors them according to their properties and the ...
-1
votes
1
answer
152
views
Convert all the newlines in a file from \r\n to \n [duplicate]
Inspired by what I'm doing at work right now.
Your program should take one parameter, the path to the file
It should convert all the windows style newlines (\r\n) to unix style (\n) and write the ...
1
vote
2
answers
453
views
Golf Me A Text-Editor [closed]
Golf Me a Text Editor
(similar challenges: Create a simple line editor and Line editor (more text here))
I seem to have forgotten which program to use to open, read, and write text files. Something ...
2
votes
0
answers
266
views
Jury-rigged Netcat from default Windows [closed]
Something unusual: a code golf question with a purpose.
I occasionally find myself in scenarios resembling the following:
Suppose you have two computers, A and B. Both of them have a fresh copy of ...
8
votes
14
answers
7k
views
Recursively count lines of code, excluding empty lines and comments
Requirement: Write a program (in any language) that counts the number of lines of code in files matching *.sh in the directory tree starting from the directory that ...
3
votes
17
answers
948
views
Rest of the path
Consider this file path:
C:/Users/Martin/Desktop/BackupFiles/PC1/images/cars/new.png
Your goal is to write a program that will return the file path starting from ...
11
votes
14
answers
3k
views
Checking a file contains only null bytes
Your goal is to write a program or function that takes in as input a string representing the path to a file, and outputs a truthy value if that file is not empty and contains no non-null bytes -- i.e.,...
19
votes
23
answers
3k
views
Insist on a new filename
At runtime, keep prompting for a line of input until the user input is not the name of an existing file or directory or other file system item, relative to the current working directory. Then return/...
-2
votes
9
answers
293
views
Extract filename from path [duplicate]
Given a printable ASCII string representing a path to a file on a POSIX-compliant system, return just the filename, i.e. remove everything until and including the last slash (...
11
votes
2
answers
628
views
Shell Glob Golfing
This task is to output the shortest path to a file, after glob expansion.
What is shell globbing? In most shells, you can use the * character in a path to ...
-4
votes
4
answers
324
views
tail: troll: file truncated
Background
When you run tail -f file in bash, the file is outputted and then any subsequent appends.
However, when you remove something that has already been ...
12
votes
14
answers
3k
views
Pad a file with zeros
Your task today will be to take an existing file and append zeros to it until it reaches a certain size.
You must write a program or function which takes the name of a file in the current directory <...