LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 03-07-2013, 01:55 PM   #1
linuxlicious
Member
 
Registered: May 2011
Posts: 87

Rep: Reputation: 6
Cli command to search and print file content without printing searchword?


So here's what I'm trying to do - I want to create a script that searches the files in /usr/share/applications for terms like "Name", "Icon", "Cathegory" and "Exec" and I want the results (without the searchwords themselves) appear in a new file in this format: name icon category exec. So basically I want to create a script to automatically populate wmdrawer with contents from the .desktop files in /usr/share/applications. How can I best accomplish this without getting too complicated? I was thinking of using a combination of "grep" and "echo" commands but grep always outputs the searchwords too. Any ideas?
 
Old 03-07-2013, 03:27 PM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Could you give a specific example? What about:

Code:
grep "foo" *.desktop | sed 's/foo//g'
?
 
Old 03-07-2013, 03:59 PM   #3
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Code:
grep -wE "Name|Exec|Icon|Categories" /usr/share/applications/*.desktop  | cut -d= -f2-

Last edited by Habitual; 03-07-2013 at 04:01 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing large file using 'lpr -P' command causes a "pause" before and during print. JimWallace Linux - Kernel 3 01-17-2012 10:32 AM
[SOLVED] [Shell]Printing Content to File whocares357 Programming 5 10-23-2010 12:43 AM
[C] Can't print in screen the content of file netpumber Programming 7 03-20-2010 04:50 PM
how to search file's content with shell? arcow Linux - Software 2 02-08-2006 10:00 AM
C: How can i print out the content of a file in pages? akin81 Programming 1 03-25-2004 08:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration