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?
-
1The input of the map is <filename,content>Jack– Jack2013-12-13 13:38:16 +00:00Commented Dec 13, 2013 at 13:38
-
I don't understand the question. Please provide sample input and your desired output.glenn jackman– glenn jackman2013-12-13 16:33:14 +00:00Commented Dec 13, 2013 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– Jack2013-12-14 03:22:26 +00:00Commented Dec 14, 2013 at 3:22
-
My question looks like this ,but the value is the content of a file,There are many lines of the file [Links]stackoverflow.com/questions/15365871/…Jack– Jack2013-12-14 03:31:33 +00:00Commented Dec 14, 2013 at 3:31
-
So, given a filename, return the contents minus a "word \t" on the first line?glenn jackman– glenn jackman2013-12-14 20:14:54 +00:00Commented Dec 14, 2013 at 20:14
|
Show 1 more comment
1 Answer
# 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
3 Comments
Jack
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
Thank you for your patience to answer,thanks very much.
Jack
Contents is a hexadecimal file content,how to retain \x00?