Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
06-25-2008, 11:43 AM
|
#1
|
LQ Newbie
Registered: Jun 2008
Posts: 2
Rep:
|
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!
|
|
|
06-25-2008, 06:54 PM
|
#2
|
Senior Member
Registered: Jun 2008
Posts: 2,529
Rep:
|
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.
|
|
|
06-25-2008, 07:07 PM
|
#3
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,443
|
ditto ... Please give example
|
|
|
06-25-2008, 11:19 PM
|
#4
|
Member
Registered: Oct 2005
Distribution: Ubuntu 7.10, OpenSUSE 10.3, Linux Mint, Arch
Posts: 92
Rep:
|
as I understand it OP wants:
Code:
{BLANK}
qwerty
rtuygfvbfgh
jhgfghjrtyg
12345
{BLANK}
turned into:
Code:
qwerty
{BLANK}
12345
|
|
|
06-25-2008, 11:42 PM
|
#5
|
Senior Member
Registered: Jun 2008
Posts: 2,529
Rep:
|
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.
|
|
|
06-26-2008, 12:09 AM
|
#6
|
LQ 5k Club
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,575
|
Quote:
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.
|
I think the OP wants 'du --time'.
This will give the directory size and time of last modification of a file in a directory.
|
|
|
06-26-2008, 06:53 AM
|
#7
|
LQ Newbie
Registered: Jun 2008
Posts: 2
Original Poster
Rep:
|
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.
|
|
|
06-26-2008, 08:13 AM
|
#8
|
Member
Registered: Mar 2008
Location: UK
Distribution: Fedora, Gentoo
Posts: 209
Rep:
|
Code:
cat file.txt | grep -C1 '^$' | grep -v '\-\-'
There may be a way to stop grep printing '--' between matched contexts, but I couldn't find it, hence the second grep.
|
|
|
All times are GMT -5. The time now is 01:50 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|