Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-15-2006, 08:41 PM   #1
LQ Newbie
Registered: Mar 2006
Posts: 4

Rep: Reputation: 0
can someone help me write a short script?

I was hoping to write a short script using 'awk' or 'bash scripting' to remove two types of strings from a file: the date, and the full directory of the item (for windows). Also, as you can tell from the use of quotes, I am quite the n00b, and simply guesssed that these might be the tools I might use to remedy this problem. So anyway, back to the problem: instead of
This Fire Franz Ferdinand 1/02/03 C:\Music\This Fire
the not yet written script would shorten it to
This Fire Franz Ferdinand
Old 03-15-2006, 09:33 PM   #2
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Let's see--you want to use Linux tools to manipulate Windows files.....Trouble lies ahead.
First, you need read/write access to the Windows filesystem--If NTFS, then Linux is not very good at that. Are you going to put the files into your Linux filesystem?

If you are simply editing multiple lines which have the same overall pattern, then sed will do it.

In your example--is this a line from a file?

More details, more help....
Old 03-15-2006, 09:45 PM   #3
LQ Newbie
Registered: Mar 2006
Posts: 4

Original Poster
Rep: Reputation: 0
Ok, it is a text file, and it is already on my ext3 partition, so no need to worry about windows .

Here is another example to make it clearer:
Numb      Linkin Park      1/20/03    C:/Music/Linkin Park/Numb
Goodbye   SR-71            1/20/03    C:/Music/SR-71/Goodbye
I want to remove the date/directory thing, so I would get:
Numb      Linkin Park
Goodbye   SR-71

Last edited by knoxville217; 03-15-2006 at 10:26 PM.
Old 03-15-2006, 10:40 PM   #4
Senior Member
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 59
im assuming its a plain text file, with all fields seperated by tabs. if thats the case, this should work:
cut -f1,2 nameoffile
by default, this will print to the screen. you can append a '> ' character to the end of that command, along with a filename, and it will send the output to that file instead of to the screen.
Old 03-16-2006, 03:16 AM   #5
Registered: Nov 2005
Distribution: xubuntu, grml
Posts: 451

Rep: Reputation: 37
when you want to use awk try this:
$ cat aa.txt
Numb      Linkin Park      1/20/03    C:/Music/Linkin Park/Numb
Goodbye   SR-71            1/20/03    C:/Music/SR-71/Goodbye
$ awk '{ print $1,$2 }' aa.txt
Numb Linkin
Goodbye SR-71


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to write a short script Baran Programming 9 04-22-2005 09:55 AM
How to write a Script Blake Linux - Software 6 07-18-2004 11:41 AM
how to write this script? MeganageM Linux - Newbie 1 03-10-2004 05:01 PM
Help with a script I need to write... cmfarley19 Programming 9 12-06-2003 12:10 PM
Short write eric.houben Linux - General 2 07-13-2001 09:12 AM

All times are GMT -5. The time now is 01:32 PM.

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