Text
stringlengths
16
168
Code
stringlengths
5
107
Create archive of photos and its contents
zip -r photos photos
Look for files under 100 KB in size.
find . -size -100k
Display the names of directories but not their contents.
ls -d
Display report.pdf with line numbers
cat -n report.pdf
Output the first 50 lines of spreadsheet.xlsx
cat spreadsheet.xlsx | head -n 50
Put contract.pdf into a new report.pdf.zip archive.
zip -c report.pdf.zip contract.pdf
Move the files to documents_archive from documents, then delete them from the source.
rsync -av --remove-source-files documents/ documents_archive
Show non-printing characters for memo.txt
cat -v memo.txt
Reverse the order of file listing
ls -r
Replace videos with memo.txt only if it's newer or doesn't exist
mv -u memo.txt videos
Clone music to archive along with its subdirectories
cp -r music archive
Zip files spreadsheet.xlsx, document.docx, report.pdf into script.py.zip, using compression level 6, verbose output, including empty directories
zip -6 -v -r0 script.py.zip spreadsheet.xlsx document.docx report.pdf
List all files with names ending in ".mp4" sorted by modification time
ls -t *.mp4
List file sizes in a way understandable to humans
ls -h
Extract encrypted report.pdf.zip with password '*.py'
unzip -P *.py report.pdf.zip
compel Without asking, copy presentation.pptx to archive.
cp -f presentation.pptx archive
Fill database.sql with executable.exe.zip
zip -c database.sql.zip executable.exe
Zip files configuration.ini, proposal.docx, policy.pdf into memo.txt.zip, displaying verbose output
zip -v memo.txt.zip configuration.ini proposal.docx policy.pdf
List contents of script.py with non-blank line numbers
cat -b script.py
Show the file's inode numbers.
ls -i
Sort files by size and display detailed information in long format
ls -Sl
Show tabs as ^I for contract.pdf
cat -T contract.pdf
Compress files using gzip
find . -type f -exec gzip {} \
Unarchive configuration.ini.zip, only extracting files matching pattern '*.pdf', quietly, and verbose output to directory scripts_backup
unzip -j -q -v -d scripts_backup configuration.ini.zip '*.pdf'
Print report.pdf with suppression of repeated empty lines
cat -s report.pdf
Find files owned by the user and group *.py
find . -type f -user *.py -group *.py
Transfer the files to reports
find . -name proposal.docx -execdir mv {} reports \
Display the contents of document.docx with the repeated blank lines disabled
cat -s document.docx
List all files in the current directory
ls -a
Transfer files larger than 1 MB from projects_backup to music
find music -type f -size +1M -exec mv {} projects_backup \;
Search for files between 1GB and 2GB in size
find . -size +1G -size -2G
Display files in order of modification timestamp
ls -t
Duplicate presentation.pptx to downloads_archive and force replacement
cp -f presentation.pptx downloads_archive
Show presentation.pptx with characters that don't print
cat -v presentation.pptx
Duplicate audio.mp3 to backup with user confirmation for overwrite
cp -i audio.mp3 backup
Find files with a size of precisely 50 bytes.
find . -size 50c
Find any files with less than 100 KB.
find . -size -100k
Show files listed in order of size
ls -S
Prompt before overwriting database.sql in backups, treat destination as file, and move only if newer
mv -iuT database.sql backups
Update report.pdf in presentation.pptx.zip if newer
zip -f presentation.pptx.zip report.pdf
Remove all files with the name policy.pdf.
find . -name policy.pdf -exec rm {} \
Clone scripts and all of its subdirectories to archive.
cp -r scripts archive
Display non-printing characters while listing the contents of database.sql
cat -v database.sql
Provide a complete list of every file in the current directory, then extract just the file names.
ls -al | awk '{print $9}'
Compress files presentation.pptx, audio.mp3, presentation.pptx into contract.pdf.zip, compressing with best compression, verbose output
zip -9 -v contract.pdf.zip presentation.pptx audio.mp3 presentation.pptx
Ignore paths when extracting files from contract.pdf.zip
unzip -j contract.pdf.zip
Sort files by size and modification time in reverse order with colored output
ls -SltrG
Copy script.py to reports_archive while keeping all of its properties.
cp -a script.py reports_archive
Force copy spreadsheet.xlsx to documents_archive without prompting, preserving attributes, and creating a backup
cp -f -p -b spreadsheet.xlsx documents_archive
Display audio.mp3 with line endings
cat -E audio.mp3
Recursively copy music to documents_archive
cp -r music documents_archive
Create a backup and force move contract.pdf to photos
mv -fb contract.pdf photos
Replace databases with spreadsheet.xlsx if it's newer or doesn't exist
mv -u spreadsheet.xlsx databases
Provide password '*.py' to extract memo.txt.zip
unzip -P *.py memo.txt.zip
Do not overwrite videos with video.mp4
mv -n video.mp4 videos
Sort files by size
ls -S
Unzip files from proposal.docx.zip ignoring directory structure
unzip -j proposal.docx.zip
Move document.docx to logs_archive, and if the files are already there, create a backup.
cp -b -i document.docx logs_archive
To photos, copy the files.
find . -name database.sql -exec cp {} photos \
Move policy.pdf to archives and overwrite existing files
mv -f policy.pdf archives
Extract configuration.ini.zip without displaying output
unzip -q configuration.ini.zip
Move image.jpg to proposal.docx.zip and add it.
zip -m proposal.docx.zip image.jpg
Display characters for video.mp4 that aren't printed
cat -v video.mp4
Make directory "videos" and unzip contents of "report.pdf.zip" into it.
mkdir videos && unzip report.pdf.zip -d videos
Allow colour output.
ls -G
Create a backup of photo.png, regard the destination as a file, display detailed feedback, and refrain from overwriting.
mv -nbvT photo.png videos
Clone report.pdf to reports_archive with attribute preservation and creating a hard link
cp -p -l report.pdf reports_archive
Count the number of directories after listing the files in reverse order based on size and modification time.
ls -Sltr | grep "^d" | wc -l
Copy document.docx to output while preserving its attributes
cp -p document.docx output
Use recursive copying to move reports to images_backup
cp -r reports images_backup
Extract files from database.sql.zip into documents_archive
unzip -d documents_archive database.sql.zip
Archive files script.py, executable.exe, video.mp4 into script.py.zip, compressing only '*.txt' files, excluding '*.tmp' files
zip -n '*.txt' -x '*.tmp' script.py.zip script.py executable.exe video.mp4
Open audio.mp3.zip, extract the contents, and replace any existing files.
unzip -o audio.mp3.zip
Replace any files that are currently in reports with configuration.ini
mv -f configuration.ini reports
Display audio.mp3 with line numbers
cat -n audio.mp3
Clone report.pdf with preserving attributes to scripts_backup
cp -a report.pdf scripts_backup
Verify configuration.ini.zip's integrity.
zip -T configuration.ini.zip
Prior to replacing spreadsheet.xlsx with templates, get confirmation.
mv -i spreadsheet.xlsx templates
Contents of executable.exe.zip are listed.
unzip -l executable.exe.zip
Force copy spreadsheet.xlsx to archive without prompting and preserving attributes
cp -f -p spreadsheet.xlsx archive
Recursively list folders and their contents
ls -R
List files one per line
ls -1
Make a hard link to duplicate configuration.ini in projects_backup.
cp -l configuration.ini projects_backup
Files are sorted by modification time.
ls -t
Move image.jpg to temp and handle it as a regular file
mv -T image.jpg temp
Print document.docx while preventing the display of several blank lines.
cat -s document.docx
Extract files with verbose output from database.sql.zip
unzip -v database.sql.zip
Print files listed individually
ls -1
Make a copy of presentation.pptx in backup while preserving all properties.
cp -a presentation.pptx backup
Copy report.pdf to logs_archive and prompt before overwriting if necessary
cp -i report.pdf logs_archive
Find empty directories
find . -type d -empty
Before replacing downloads with script.py, prompt
mv -i script.py downloads
List files inside presentation.pptx.zip
unzip -l presentation.pptx.zip
List subdirectories in a recursive manner with comprehensive details, and then determine the overall disc consumption.
ls -Rl | du -h
Enumerate files with expanded properties.
ls -l
Delete files with name database.sql
find . -name database.sql -delete
Silently unzip the files from image.jpg.zip.
unzip -q image.jpg.zip
Display verbose output while extracting policy.pdf.zip
unzip -v policy.pdf.zip
List all files in the current directory with detailed information, then sort them by modification time in reverse order
ls -al | sort -k6,6r
Delete empty directories
find . -type d -empty -delete