Brky
Brky

Reputation: 59

Remove file name from file in bash

I need to remove names from output of file.

I am using

file $variable -N

then i use sed

but it didn't work.

Output of file is

./: directory
./whatever: data
./testfile: ASCII text

and I expect output from sed

directory
data
ASCII text

Thanks for help!

Upvotes: 0

Views: 50

Answers (1)

sat
sat

Reputation: 14949

You don't need any external command. Use -b option in file command.

file -b file

From man file:

-b, --brief
      Do not prepend filenames to output lines (brief mode).

Upvotes: 1

Related Questions