|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Deleting file name
I need a way to remove all the file names with they are extension from a line of a document. For example: I have doc named "gara" with the following content: Code:
/media/gogo/6651-FEAB/Desktop/Desktop.jpg /media/gogo/6651-FEAB/Desktop.pdf /media/gogo/6651-FEAB/linux/logo1.jpg /media/gogo/6651-FEAB/eks/HDD.Regenerator.2011-RES/INFOS/Proud Lion.doc i need a way to remove the Desktop.jpg from the first line, Desktop.pdf from second line, Code:
logo1.txt from 3 ed line and Proud Lion.doc from the 4 th line. Thanks in advance. Last edited by Scott; 01-30-2013 at 05:30 AM.. Reason: Code tags |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Code:
$ sed 's!^\(.*\)/[^/]*$!\1/!' gogok.txt /media/gogo/6651-FEAB/Desktop/ /media/gogo/6651-FEAB/ /media/gogo/6651-FEAB/linux/ /media/gogo/6651-FEAB/eks/HDD.Regenerator.2011-RES/INFOS/ |
| The Following User Says Thank You to zazzybob For This Useful Post: | ||
gogok_bg (01-30-2013) | ||
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Code:
awk -F"/" '{OFS="/";$NF="";print}' gara |
|
#4
|
|||
|
|||
|
that forum may be the best think that have happened to me
BIG THX ps: can you recommend any good places with tutorials for nubs lime me who are starting to with linux and trying to write screpts :> ? |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
a great book : Unix programming environment by kernighan and rob pike
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Deleting a pattern in UNIX without deleting the entire line | Alyaa | UNIX for Dummies Questions & Answers | 15 | 03-15-2013 12:06 AM |
| awk - writing matching pattern to a new file and deleting it from the current file | goddevil | Shell Programming and Scripting | 2 | 12-01-2012 03:57 PM |
| Deleting the Last value from a file | theeights | Shell Programming and Scripting | 7 | 02-23-2010 12:50 AM |
| Help deleting a file | shirtee | UNIX for Dummies Questions & Answers | 2 | 12-06-2007 10:43 AM |
| Deleting lines inside a file without opening the file | toms | Shell Programming and Scripting | 3 | 09-24-2007 07:58 AM |
|
|