Text file

From Linux Bash Shell Scripting Tutorial Wiki
Jump to navigation Jump to search
  • A text file (flatfile) is a Linux file with plain text only data.
  • A text file cannot store pictures or other binary data.
  • End of text file is marked using spacial characters called an end-of-file marker.
  • Text file examples:
    • Linux configuration files stored in /etc or $HOME/.dotfile
    • A shell script

To determine file type

To determine file file (binary or text file) type use the file command:

file filename
file /path/to/file
file /etc/resolv.conf
file /dev/sda1
file /dev/stdin
file /tmp/fact.c

Sample outputs:

/etc/resolv.conf: ASCII text
/dev/sda1: block special
/dev/stdin: symbolic link to `/proc/self/fd/0'
/tmp/fact.c: ASCII C program text

To see a text file

Type the following command to view text file contains:

cat filename


more filename


less filename

To create a text file

  • You need to use a text editor such as vi or emacs for editing and creating plain text files.