Linux open data file

Как просмотреть содержимое файла .dat в linux

У меня есть файл с расширением .dat, как я могу просмотреть содержимое файла в гекса? Я имею в виду, что если я открою файл, я смогу увидеть содержимое в шестнадцатеричном формате, это можно сделать с помощью редактора vim. Я установил tnef, но когда я пытаюсь открыть этот файл, он говорит: «Кажется, что это не файл TNEF»

6 ответов 6

Во-первых, файл dat может быть чем угодно. Используйте file .dat чтобы найти его. Затем, в зависимости от его типа, используйте конкретное приложение, чтобы открыть его.

file — хорошая команда, чтобы попробовать сначала.

После этого я использую cat -v | less или od -a | less для «читабельного» представления. Проверьте man страницы для od и file .

xxd более современен, чем od , и часто генерирует более красивое представление, но иногда доступен только od .

Конечно, у mc (во многих серьезных дистрибутивах, доступных с базового установочного CD) есть HEX viewer. Доступ к режиму просмотра идентификатора можно получить с помощью F4.

это можно сделать с помощью редактора vim [?].

Итак, как обычно, откройте файл в vi, нажмите escape и введите :%!xxd для перехода в шестнадцатеричный режим

И когда вы закончите, нажмите [escape] еще раз и наберите :%!xxd -r для выхода из шестнадцатеричного режима.

Хорошо, так что это не то, чтобы на самом деле переключаться в «шестнадцатеричный режим» vi; Ви не имеет. То, что на самом деле делает выше, — это поток буфера vi через внешнюю программу ‘xxd’.

Попробуйте добавить следующее в /etc/vim/vimrc.local , и вы получите сочетания клавиш для переключения вперед и назад (F8 и F7).

" Switch to hex-editor` noremap :%!xxd " Switch back noremap :%!xxd -r

Источник

Читайте также:  Kali linux vbox guest additions

How to view the contents of .dat file in linux

I have a file with .dat extension how can i view the contents of the file in hexa ? mean if i open the file i should be able to see the contents in hex format, can this be done using vim editor. I have installed tnef but when i try opening this dat file it says «Seems not to be a TNEF file»

That depends on what the file is. .dat is such a generic extension that it could be anything. Where did you get the file from? What type of data do you expect to be contained in the file?

6 Answers 6

Firstly, the dat file can be anything.

Use file .dat to find what it is. Then depending out its type, use specific application to open it.

Some common Linux utilities for viewing hex dumps are:

file is a good command to try first.

After that, I use cat -v | less or od -a | less for a «readable» view. Check the man pages for od and file .

xxd is more modern than od , and often generates a prettier view, but sometimes only od is available.

Of course mc (in many serious distros available from basic install CD) has HEX viewer. It can be accessed id view mode by F4

can this be done using vim editor[?].

So, open a file in vi as usual, hit escape and type: :%!xxd to switch into hex mode

And when your [sic] done hit escape again and type: :%!xxd -r to exit from hex mode.

Okay, so this isn’t actaully switching to vi’s ‘hex mode’; vi doesn’t have one. What the above actually does is to stream vi’s buffer through the external program ‘xxd’.

Try adding the following to /etc/vim/vimrc.local , and you’ll get keyboard shortcuts for switching back and forth (F8 and F7).

" Switch to hex-editor` noremap :%!xxd " Switch back noremap :%!xxd -r

There is also a Vim tip on this subject.

Читайте также:  Kali linux spoof dns

Источник

Red Hat

Member Information Avatar

15, 0

What is the command that can be used to open or view the .dat file in linux?

Unable to read the contents of .dat file.

Member Information Avatar

2,977, 644

Member Information Avatar

15, 0

Thanks for your immediate response..

I have tried that too already. But of no use. Its not giving any output.
So is any other command available?

Member Information Avatar

406, 72

Member Information Avatar

2,977, 644

1) what is the name of your file ?

2) please post the result of the commands

type strings file yourfile.dat

Member Information Avatar

15, 0

type strings
strings is /usr/bin/strings

file hr_rrate_127aws.dat
hr_rrate_127aws.dat: data

Member Information Avatar

2,977, 644

ls -l hr_rrate_127aws.dat strings hr_rrate_127aws.dat wc -l hr_rrate_127aws.dat uname -a

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to use ‘ls’ command to list files like *.dat, not *.*.dat?

Discussion started by: pmcginni777

2. UNIX for Beginners Questions & Answers

Convert EBCDIC(.DAT) FILE into ASCII FILE

Hi Team, I am having 100 EBCDIC files (i.e. DAT extension) and need to convert them into ASCII File by unix shell script. I tried with DD Command but its not providing output as expected. Sample Text: —————— ��������@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Expected Output. (2 Replies)

Discussion started by: JSM

3. Answers to Frequently Asked Questions

How to split a dat file based on another file ni UNIX?

i have two files , one is var.txt and another res.dat file var.txt contains informaton like below date,request,sales,item 20171015,1,123456,216 20171015,1,123456,217 20171015,2,345678,214 20171015,3,456789,218 and res.dat contains is a one huge file contains information like. (1 Reply)

Discussion started by: pogo

4. Shell Programming and Scripting

Execution of loop :Splitting a single file into multiple .dat file

hdr=$(cut -c1 $path$file|head -1)#extract header�H� trl=$(cut -c|path$file|tail -1)#extract trailer �T� SplitFile=$(cut -c 50-250 $path 1$newfile |sed’$/ *$//’ head -1′)# to trim white space and extract table name If; then # start loop if it is a header While read I #read file Do. (4 Replies)

Discussion started by: SwagatikaP1

5. Shell Programming and Scripting

FASTEN count line of dat file and compare with the CTRL file

Hi All, I thinking on how to accelerate the speed on calculate the dat file against the number of records CTRL file. There are about 300 to 400 folder directories that contains both DAT and CTL files. DAT contain all the flat files records CTL is the reference check file for the. (3 Replies)

Читайте также:  Loaded shared libraries linux
Discussion started by: ckwan

6. UNIX for Dummies Questions & Answers

ID incorrect field values in dat file and output to new file

Hi All I have a .dat file, the values are seperated by «. I wish to identify all field values in field 14 that are not ’01-APR-2013′ band then copy those records to a new file. Can anyone suggest the UNIX command required. Thanks in advance Andy (2 Replies)

Discussion started by: aurum1313

7. UNIX for Advanced & Expert Users

Search in .dat file

Discussion started by: Deeptanshu

8. Red Hat

How to view all files on DAT tape

I’m using tar and so far so good, but how can I view ALL files without having to fast forward and rewind the tape? Let’s say I append 100 files onto the tape. Having to fast forward 100 times until I find the file I want is kinda tedious. (3 Replies)

Discussion started by: sdotsen

9. Shell Programming and Scripting

Performance issue in UNIX while generating .dat file from large text file

Hello Gurus, We are facing some performance issue in UNIX. If someone had faced such kind of issue in past please provide your suggestions on this . Problem Definition: /Few of load processes of our Finance Application are facing issue in UNIX when they uses a shell script having below. (19 Replies)

Discussion started by: KRAMA

10. Shell Programming and Scripting

How to attach an excel file/ dat file thru unix mails

Hi. I want to attach a .xls or .dat file while sending mail thru unix. I have come across diff attachments sending options, but allthose embeds the content in the mail. I want the attachement to be send as such. Please help me out. regards Diwakar (1 Reply)

Источник

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