I have many lines like the following in a file(there are also other kinds of lines)
and in these lines, fields which starts with "Host:", "Ports:" are separated by '\tab'. The number of fields in different lines may be different, which means that maybe in this line there are only fields starts with "Host:", "Ignored States:", while in another line the fields are as the above.
Now, I want to process these lines so that different fields are written into different files, like fields starting with "Hosts:" are written into file host.log, bla bla
------------------------------------------
the content of the file is like the following, and I want to process the 3rd and 7th line
Moderator's Comments:
When you use code tags for the 2nd snippet, use them for the 1st too please.
Last edited by zaxxon; 08-23-2012 at 08:26 AM..
Reason: code tags
thanks, but maybe my explanation is not clear in the original post,
actually
the file is like this
so there are many lines like the 3rd and the 7th lines
there are many fields in these lines, separated by '\t'
and I want to extract the fields and put them into different log files.
for example, in hosts.log, I will have
hosts.log is special coz there are sub-fields separated by ','
in Seq_Index.log, I will have
in ip_id.log,I will have
Quote:
Originally Posted by pamu
Its depend on what you want to achieve.
Please provide some more lines of your input.
do you notice these two lines, the 3rd and the 7th lines
I want to creates several log files, which correspond to 4 keywords: Ports, Seq Index, OS, IP ID
but different lines may have different keywords
like in these two lines there are no "OS", in the first line there is no "IP ID"
in each log file, I want to have the character string which is just after the keyword, like in the Seq_index.log, I want to have 196(in the 3rd line), 207(in the 7th line), ........
let me give u a metaphor, there is a demographic list, listing ppl's name, sex, age, location
I want to get statistics like proportion of males, distribution of ages, so I want to get several files like sex.log, age.log, location.log.
Hi,my file is in this format
",
\"symbol\": \"Rbm38\"
} ]"
I want to convert it to a more user readable format
_id pubmed text symbol
67196 18667844 Overexpression of UBE2T in NIH3T3 cells significantly promoted colony formation in mouse cell cultures Ube2t
56190 21764855 ... (3 Replies)
hello All, I'm new to AWK programming and learned myself few things to process a file and deal with duplicate lines, but I got into a scenario which makes me clueless to handle. Here is the scenario..
Input file:
user role
----- ----
AAA add
AAA delete
BBB delete
CCC delete
DDD ... (10 Replies)
I dispose of two tab-delimited files (the first column is the primary key):
File 1 (there are multiple rows sharing the same key, I cannot merge them)
A 28,29,30,31
A 17,18,19
B 11,13,14,15
B 8,9File 2 (there is one only row beginning with a given key)
A 2,8,18,30,31
B ... (3 Replies)
Hello,
I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this :
This is the output of ls command : I stored the output in a file filelist
1.1M... (5 Replies)
Input File:
1234, 2345,abc
1,24141,gw
222,rff,sds
2232145,sdsd,121
Output file to be generated:
000001234,2345,abc
000000001,24141,gw
000000222,rff,sds
002232145,sdsd,121
i.e; the first column is padded to get 9 digits.
I tried with following: (1 Reply)
I have a file, first 5 columns are very normal, like "1107",106027,71400,"Y","BIOLOGY",,
however, the 6th columns, the user can put comments, anything, just any characters, like new line, double quote, single quote, whatever from the keyboard, like"Please load my previous SOM597G course content in... (3 Replies)
I am trying to process file which has following data
#23456789012345
ACNASPSA13N0N0
ACNAPCPA05N0N0
ACNAFATS11N0N0
I want to take out each line from the file and what to put in the file by name which if part of the line starting from offset 10 to 15. It means I want to create three file... (3 Replies)
Hi all
Is there a way in awk to know that you are processing your final line of input if you do no know how many lines were in the input to begin with?
Thanks (7 Replies)