Linux command for file version

How to Find Out File Types in Linux

The easiest way to determine the type of a file on any operating system is usually to look at its extension (for instance .xml, .sh, .c, .tar etc..). What if a file doesn’t have an extension, how can you determine its type?

Linux has a useful utility called file which carry out some tests on a specified file and prints the file type once a test is successful. In this short article, we will explain useful file command examples to determine a file type in Linux.

Note: To have all the options described in this article, you should be running file version 5.25 (available in Ubuntu repositories) or newer. CentOS repositories have an older version of file command (file-5.11) which lacks some options.

You can run following command to verify the version of file utility as shown.

$ file -v file-5.33 magic file from /etc/magic:/usr/share/misc/magic

Linux file Command Examples

1. The simplest file command is as follows where you just provide a file whose type you want to find out.

Find File Type in Linux

2. You can also pass the names of the files to be examined from a file (one per line), which you can specify using the -f flag as shown.

Find Files Type in Filename List

3. To make file work faster you can exclude a test (valid tests include apptype, ascii, encoding, tokens, cdf, compress, elf, soft and tar) from the list of tests made to determine the file type, use the -e flag as shown.

$ file -e ascii -e compress -e elf etc

4. The -s option causes file to also read block or character special files, for example.

$ file -s /dev/sda /dev/sda: DOS/MBR boot sector, extended partition table (last)

5. Adding the -z options instructs file to look inside compressed files.

Determine Compressed Files

6. If you want to report information about the contents only not the compression, of a compressed file, use the -Z flag.

Читайте также:  Astra linux редактор разделов

7. You can tell file command to output mime type strings instead of the more traditional human readable ones, using the -i option.

$ file -i -s /dev/sda /dev/sda: application/octet-stream; charset=binary

8. In addition, you can get a slash-separated list of valid extensions for the file type found by adding the –extension switch.

For more information and usage options, consult the file command man page.

That’s all! file command is a useful Linux utility to determine the type of a file without an extension. In this article, we shared some useful file command examples. If you have any questions or thoughts to share, use the feedback form below to reach us.

Источник

Linux get version of file command prompt

To visualize several old versions of one file, the simplest mean is to display its version tree ( ), and then select a version, right-click on it and ‘ ‘ an editor which accepts multiple files (like Notepad++). But to visualize several old versions of different files, I would recommend a dynamic view and editing the config spec of that view (and not the snapshot view you are currently working with), in order to quickly select all those old files (hopefully through a simple select rule like ‘ ‘)

Check PDF file version from command line

Yes. The file command covers this

$ file x1.pdf x1.pdf: PDF document, version 1.7 $ 

To get greater detail, you could try pdfinfo , part of popper-utils.

$ pdfinfo x1.pdf Title: Full page photo Author: steve Producer: Microsoft: Print To PDF CreationDate: Fri Apr 5 10:14:34 2019 ModDate: Fri Apr 5 10:14:34 2019 Tagged: no UserProperties: no Suspects: no Form: none JavaScript: no Pages: 9 Encrypted: no Page size: 841.5 x 594.75 pts Page rot: 0 File size: 5424973 bytes Optimized: no PDF version: 1.7 $ 

How to find the browser versions from command-line in Linux, In ubuntu when I just open a terminal and say «firefox -v» or «konqurer -v» it prints all the version information. Previously on Windows xp

Linux — command line to get version of terminal

echo $TERM tells you kind of terminal you are using, eg. xterm

Use the ps command with no arguments to get the processes running under the current shell.

% ps PID TTY TIME CMD 1917 pts/0 00:00:00 zsh 13659 pts/0 00:00:00 ps 

How to Find Out File Types in Linux, To find out file types we can use the file command. Syntax: file [OPTION…] [FILE…] You can run the following command to verify the version

Читайте также:  Node js linux команды

In ClearCase, how can I view old version of a file in a static view, from the command line?

I’m trying to look at a bunch of old versions

I am not sure if you are speaking about «a bunch of old versions» of one file , «a bunch of old versions» from several files.

To visualize several old versions of one file, the simplest mean is to display its version tree ( ct lsvtree -graph File ), and then select a version, right-click on it and ‘ Send To ‘ an editor which accepts multiple files (like Notepad++). In a few click you will have a view of those old versions.
Note: you must have CC6.0 or 7.0.1 IFix01 (7.0.0 and 7.0.1 fail to ‘sent to’ a file with the following error message » Access to unnamed file was denied «)

But to visualize several old versions of different files, I would recommend a dynamic view and editing the config spec of that view (and not the snapshot view you are currently working with), in order to quickly select all those old files (hopefully through a simple select rule like ‘ element * aLabel ‘)

what’s the idiomatic way to «cat» an earlier revision of a file?

The idiomatic way is through a dynamic view (that you configure with the exact same config spec than your existing snapshot view).

You can then browse (as in ‘change directory to’) the various extended paths of a file.

If you want to cat all versions of a branch of a file, you go in:

cd /view/MyView/vobs/myVobs/myPath/myFile@@/main/[. ]/maBranch cat 1 cat 2 . cat x 

‘ 1 ‘, ‘ 2 ‘, . ‘ x ‘ being the version 1, 2, . x of your file within that branch.

For a snapshot view , the extended path is not accessible , so your «hack» is the way to go.

(one line version for copy-paste, Unix syntax:)

cleartool find addon.xml -ver 'brtype(aBranch) && !version(. /aBranch/LATEST) && ! version(. /aBranch/0)' -exec 'cleartool diff -ser empty "$CLEARCASE_XPN"'

(multi-line version for readability:)

cleartool find addon.xml -ver 'brtype(aBranch) && !version(. /aBranch/LATEST) && ! version(. /aBranch/0)' -exec 'cleartool diff -ser empty "$CLEARCASE_XPN"'

(one line version for copy-paste, Unix syntax:)

cleartool find addon.xml -ver 'brtype(aBranch) && !version(. /aBranch/LATEST) && ! version(. /aBranch/0)' -exec 'cleartool diff -ser empty "$CLEARCASE_XPN"' | ccperl -nle '$a=$_; $b = $a; $b =~ s/^>+\s(?:file\s+\d+:\s+)?//g;print $b if $a =~/^>/'

(multi-line version for readability:)

cleartool find addon.xml -ver 'brtype(aBranch) && !version(. /aBranch/LATEST) && ! version(. /aBranch/0)' -exec 'cleartool diff -ser empty "$CLEARCASE_XPN"' | ccperl -nle '$a=$_; $b = $a; $b =~ s/^>+\s(?:file\s+\d+:\s+)?//g; print $b if $a =~/^>/'

That way, the output is nicer.

Читайте также:  Apt cd rom add astra linux

The » cleartool get » command (man page) mentioned below by Brian don’t do stdout:

The get command copies only file elements into a view.

On a UNIX or Linux system, copy /dev/hello_world/foo.c@@/main/2 into the current directory.

cmd-context get –to foo.c.temp /dev/hello_world/foo.c@@/main/2 

On a Windows system, copy \dev\hello_world\foo.c@@\main\2 into the C:\build directory.

cmd-context get –to C:\build\foo.c.temp \dev\hello_world\foo.c@@\main\2 

So maybe than, by piping the result to a cat (or type in windows), you can then do something with the output of said cat ( type ) command.

cmd-context get –to C:\build\foo.c.temp \dev\hello_world\foo.c@@\main\2 | type C:\build\foo.c.temp 

I know this is an old thread. but I couldn’t let this thrashing go by unresolved.

Static views have a «ct get» command that does exactly what you are looking for.

cleartool get -to ~/foo File@@/main/28 

will save this version of the file in ~/foo .

[ Rewritten based on the first comment ]

All files in Clearcase, including versions, are available in the virtual directory structure. I don’t have a lot of familiarity with static views, but I believe they still go through a virtual fs; they just get updated differently.

In that case, you can just do:

It can get ugly if you also have to find the right version of a directory that contained that file element. We have a PERL script at work that uses this approach to analyze historical changes made to files, and we quickly ran out of command-line space on Windows to actually run the commands!

Shell — linux — command line to get version of terminal, Use the ps command with no arguments to get the processes running under the current shell. Example: % ps PID TTY TIME CMD 1917 pts/0

Источник

Оцените статью
Adblock
detector