1

I want to process PCAP file,then use WholeFileInputFormat. The input of the map is <filename,content>. How to get the content by using shell script?

glenn jackman
  • 238,783
  • 38
  • 220
  • 352
Jack
  • 13
  • 2
  • 1
    The input of the map is – Jack Dec 13 '13 at 13:38
  • I don't understand the question. Please provide sample input and your desired output. – glenn jackman Dec 13 '13 at 16:33
  • The input of the mapper is a file like "key \t this is the value,and I \n want to get the value. " . The output I want to get is the part of that file, like "this is the value,and I \n want to get the value.", how to use shell scripts to do it? – Jack Dec 14 '13 at 03:22
  • My question looks like this ,but the value is the content of a file,There are many lines of the file [Links]http://stackoverflow.com/questions/15365871/code-for-parsing-a-key-value-in-in-file-from-shell-script – Jack Dec 14 '13 at 03:31
  • So, given a filename, return the contents minus a "word \t" on the first line? – glenn jackman Dec 14 '13 at 20:14
  • yes,That's what I mean,I want the content of the TAB later,how to do this using shell script? thank you . – Jack Dec 15 '13 at 12:17

1 Answers1

0
# test file:
echo -e "foo bar\tthis is\nthe rest of the content" > file

contents=$( sed '1s/[^\t]*\t//' file )
label=$( sed '1{ s/\t.*//; q }' file )

You must quote the variables to preserve whitespace.

echo "$label"
echo "$contents"

You should always quote variables unless you know specifically why you shouldn't

glenn jackman
  • 238,783
  • 38
  • 220
  • 352
  • When I echo $contents,I get "this is the rest of the content".But I want to keep this contents in 2 rows,in other words,I wish to retain the '\n'. – Jack Dec 16 '13 at 04:34
  • Thank you for your patience to answer,thanks very much. – Jack Dec 16 '13 at 11:06
  • Contents is a hexadecimal file content,how to retain \x00? – Jack Dec 17 '13 at 04:00