grab the line below a blank line and the line above the next blank line awk or perl?
Hello,
I am trying to grab the full line below a blank line and the full line above the next blank line, group them together and throw a blank line inbetween them and the next entry like that in the output. There might also be an easier way, I am trying to get the folder size and the last access time of that folder to make an audit. Any help would be appreciated. Thanks! |
How about showing us the real command output you are trying to parse, and how you want it to look. I'm pretty confused with your description.
|
ditto ... Please give example
|
as I understand it OP wants:
Code:
{BLANK} Code:
qwerty |
That may very well be, but the issue is one of forcing a method of implementation based upon the OPs current perception of how to obtain an answer to a given problem.
A better method would be to describe the goal more precisely (eg. "how do I get total folder size and last access time of a file in a folder?") rather than focusing on the implementation ("how to I solve some problem using some tool I'm not sure is the right tool"). If I am correct in what the user is asking, this is not the best or easiest approach. But I'll wait the OP to clarify. |
Quote:
This will give the directory size and time of last modification of a file in a directory. |
I finagled a way to get the output I desired. It wasn't the most elegant approach. I wanted
{BLANK} qwerty rtuygfvbfgh jhgfghjrtyg 12345 {BLANK} 67890 44444 88888 {blank} turned into {blank} qwerty 12345 {blank} 67890 88888 {blank} basicly just take the first and last lines in a block of text and group them together. |
Code:
cat file.txt | grep -C1 '^$' | grep -v '\-\-' |
All times are GMT -5. The time now is 06:03 AM. |