Back to commands

Linux Survival Basics

Read-only

Detect Script Line Endings with file

You need to know whether a script is shell text with CRLF or normal Unix line endings.

Command

file script.sh

Before you run this

System impact: Read-only. Low when scoped to the shown target.

When not to use it: Do not treat file output as proof the script is safe to execute.

Expected output

File type and line-ending hints such as shell script text executable with CRLF line terminators.

System impact

Read-only. Nothing changes. The command reads current state and prints diagnostic evidence.

Recovery / rollback: no state is changed.

When to use it

Use when `cat -v` suggests hidden carriage returns.

When not to use it

Do not treat file output as proof the script is safe to execute.

Example run

Commands shown

These are the commands shown for inspection. Treat them as an example, not proof that your system will behave identically.

  1. file script.sh
  2. file script.sh

next steps

Related commands

Linux Survival Basics Can be slow

Find CRLF Lines in a Script

Find exactly which lines still contain carriage returns.

grep -n $'\r' script.sh | head
Linux Survival Basics Can be slow

Count Source Files by Extension

A quick extension count can show whether expected content made it into the source tree.

find source -type f -printf '%f\n' | sed -n 's/.*\.//p' | sort | uniq -c | sort -nr
Linux Survival Basics Can be slow

Find the Files Eating Your Disk

The disk was full, but guessing at folders was the slow part.

find /var -type f -printf '%s %p\n' | sort -nr | head -20

next diagnostic step

Where to go from this command

Study mapping

Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.

  • LPIC-1 style command-line practice
  • LFCS style performance-task practice

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.