Text
stringlengths
16
168
Code
stringlengths
5
107
Find directories with names containing 'backup' and not writable by others
find . -type d -name "*backup*" ! -perm -o=w
Move spreadsheet.xlsx to scripts if it's newer or doesn't already exist there
mv -u spreadsheet.xlsx scripts
List directories before files
ls --group-directories-first
Zip files configuration.ini, presentation.pptx, spreadsheet.xlsx into executable.exe.zip, using password 'pass123', excluding '*.tmp' files
zip -P pass123 -x '*.tmp' executable.exe.zip configuration.ini presentation.pptx spreadsheet.xlsx
Save a backup of spreadsheet.xlsx, do not overwrite, and show verbose feedback
mv -nbv spreadsheet.xlsx reports
Display directories only
ls -d
Display subfolders iteratively
ls -R
Change directory to output and extract files from document.docx.zip
unzip -C output document.docx.zip
Check that memo.txt.zip is intact.
zip -T memo.txt.zip
If files already exist, replicate document.docx to logs_archive and make backups.
cp -b document.docx logs_archive
Out of presentation.pptx.zip, remove proposal.docx.
zip -d presentation.pptx.zip proposal.docx
Show tabs as ^I for policy.pdf
cat -T policy.pdf
Display files in contract.pdf.zip
unzip -l contract.pdf.zip
List the contents of presentation.pptx while suppressing the repetitive blank lines.
cat -s presentation.pptx
Delete empty directories
find . -type d -empty -delete
Move spreadsheet.xlsx to downloads_archive in duplicate, then replace it.
cp -f spreadsheet.xlsx downloads_archive
Extract files with verbose mode enabled from image.jpg.zip
unzip -v image.jpg.zip
Display contents of photo.png.zip
unzip -l photo.png.zip
Place proposal.docx inside of contract.pdf.zip
zip -u contract.pdf.zip proposal.docx
List directories first, followed by files
ls --group-directories-first
Duplicate proposal.docx to photos_backup with user confirmation for overwrite
cp -i proposal.docx photos_backup
Sort files by modification time and display file sizes in human-readable format, then count the number of lines
ls -lt | awk '{print $5}' | wc -l
Files in report.pdf.zip are shown.
unzip -l report.pdf.zip
If files already exist, duplicate spreadsheet.xlsx to projects_backup using a backup.
cp -b -i spreadsheet.xlsx projects_backup
Duplicate memo.txt to music_library and request confirmation before overwriting
cp -i memo.txt music_library
Find files with names containing 'report' and with permissions 644
find . -type f -name "*report*" -perm 644
If video.mp4 is outdated or doesn't exist, move it to databases.
mv -u video.mp4 databases
While extracting files, extract image.jpg.zip
unzip -q image.jpg.zip
Check for updates and add video.mp4 to audio.mp3.zip
zip -u audio.mp3.zip video.mp4
List directories rather than the contents therein.
ls -d
Replicate spreadsheet.xlsx to music_library while retaining its attributes, creating a hard link, and making a backup
cp -p -l -b spreadsheet.xlsx music_library
List the directories on their own.
ls -d
Extract files from proposal.docx.zip and change to output
unzip -C output proposal.docx.zip
Move audio.mp3 to templates with force, prompt for confirmation, and move only if newer
mv -ifu audio.mp3 templates
Forcefully move presentation.pptx to photos, but ask for approval
mv -if presentation.pptx photos
Look for files that have the name report.pdf.
find . -name report.pdf
Ask before replacing script.py in temp and treat destination as a file
mv -Ti script.py temp
Delete empty directories
find . -type d -empty -delete
List the lines that make up report.pdf in the list.
cat -n report.pdf
Unzip files from proposal.docx.zip ignoring directory structure
unzip -j proposal.docx.zip
Move image.jpg as a normal file to databases.
mv -T image.jpg databases
Enumerate all files, even hidden ones, with the word "log" in their names.
ls -a *log*
Unarchive spreadsheet.xlsx.zip, quietly and extracting to standard output to directory temp_folder
unzip -q -p -d temp_folder spreadsheet.xlsx.zip
Backup downloads to backup and preserve directory structure
cp -r downloads backup
Verify configuration.ini.zip's integrity.
zip -T configuration.ini.zip
Zip configuration.ini ignoring directory structure
zip -j presentation.pptx.zip configuration.ini
Update existing files in database.sql.zip
zip -u database.sql.zip contract.pdf
Find files with names containing 'important' and modified in the last 30 days
find . -type f -name "*important*" -mtime -30
List the lines that make up presentation.pptx in the list.
cat -n presentation.pptx
List all files having "backup" in their names with detailed information
ls -l *backup*
Display file information in extended format
ls -l
Extract files and overwrite existing files from document.docx.zip
unzip -o document.docx.zip
Check for corruption with configuration.ini.zip.
zip -T configuration.ini.zip
Locate files named photo.png
find . -name photo.png
List all files beginning with "data" in reverse order
ls -r data*
Output the first 20 lines of video.mp4
cat video.mp4 | head -n 20
Display directories prior to files
ls --group-directories-first
List contents of memo.txt with non-printing characters displayed
cat -v memo.txt
Show files listed in order of modification time
ls -t
Create directory photos and parent directories if they do not exist
mkdir -p photos
Remove all files with the name executable.exe.
find . -name executable.exe -exec rm {} \
List contents of spreadsheet.xlsx quietly
cat -q spreadsheet.xlsx
Extract files from database.sql.zip quietly
unzip -q database.sql.zip
List all "important" files with sizes that can be read by humans.
ls -h *important*
List files in reverse order of modification time
ls -r
Create directory reports with verbose output
mkdir -v reports
Include directories first, then files.
ls --group-directories-first
List contents of video.mp4 with buffered output suppression
cat -u video.mp4
Organise files according to when they were last modified and provide file sizes in a legible manner.
ls -ltSh
Sort files by modification time and display file sizes in human-readable format with colored output
ls -lt -hG
Place photo.png inside of report.pdf.zip.
zip -u report.pdf.zip photo.png
Make a hard link by copying script.py to projects_backup and maintaining all of its properties.
cp -p -l script.py projects_backup
Insert spreadsheet.xlsx inside the configuration.ini.zip archive.
zip -u configuration.ini.zip spreadsheet.xlsx
Print executable.exe contents with line endings
cat -E executable.exe
Make a backup of video.mp4, don't replace it, and only move it if it's more recent.
mv -nbu video.mp4 presentations
Display files in order of modification timestamp
ls -t
Verify image.jpg.zip's integrity.
unzip -t image.jpg.zip
List files in long format with colored output
ls -lG
Look for files with name image.jpg
find . -name image.jpg
Zip photo.png disregards the directory hierarchy
zip -j policy.pdf.zip photo.png
List the contents of image.jpg.zip.
unzip -l image.jpg.zip
Look for files with the name policy.pdf.
find . -name policy.pdf
Backup temp to backup and maintain its attributes with recursive copying
cp -r -p temp backup
Show hidden files and directories in long format with colored output and detailed information
ls -alG
List file sizes in a human-friendly format
ls -h
Compile and transfer configuration.ini to configuration.ini.zip.
zip -u configuration.ini.zip configuration.ini
Verify integrity of spreadsheet.xlsx.zip
unzip -t spreadsheet.xlsx.zip
While maintaining its properties, copy configuration.ini to logs_archive and establish a hard link.
cp -p -l configuration.ini logs_archive
List all files in long format whose names begin with "file" recursively.
ls -lR file*
Compress files document.docx, presentation.pptx, executable.exe into spreadsheet.xlsx.zip, compressing only '*.txt' files
zip -n '*.txt' spreadsheet.xlsx.zip document.docx presentation.pptx executable.exe
Create zip of backups and its contents
zip -r backups backups
Show tabs as ^I for contract.pdf
cat -T contract.pdf
Files are sorted by date of modification.
ls -t
Replicate photos to photos of destination recursively
cp -r photos archive
Decompress video.mp4.zip, extracting files matching pattern '*.csv', quietly, and testing archive integrity only to directory temp_folder
unzip -j -q -t -d temp_folder video.mp4.zip '*.csv'
Prompt before overwriting database.sql in downloads, treat destination as file, and display verbose output
mv -iTv database.sql downloads
Zip files contract.pdf, video.mp4, policy.pdf into image.jpg.zip, using password 'pass123', verbose output
zip -P pass123 -v image.jpg.zip contract.pdf video.mp4 policy.pdf
Compress files spreadsheet.xlsx, audio.mp3, script.py into memo.txt.zip, storing file attributes, excluding '*.tmp' files, silently
zip -X -x '*.tmp' -q memo.txt.zip spreadsheet.xlsx audio.mp3 script.py
Move script.py to logs and provide verbose feedback
mv -v script.py logs
Concatenate contract.pdf and audio.mp3
cat contract.pdf audio.mp3