This is a quick post on how to remove the first word of a line.
There are lot of ways on how to remove and strip out the first word of a line from a text file. Here's one way to achieve that.
# cat testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
my blog name is sysad linux blog
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Assuming we need to strip down or remove the word 'my' from the above line, that would be basically easy using linux binary tools. One approach would be using awk like so
Here's how to remove the first word of a line from textfiles using static approach via awk and cut linux tool.
Working on same content of previous file
# cat testfile.txt | awk '{print $2,$3,$4,$5,$6,$7}'
output
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
blog name is sysad linux blog
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Using cut, that would be
# cat testfile.txt | cut -d' ' -f2,3,4,5,6,7
That's it, enjoy.
Related Articles:
Get the Filename Extension Only
Strip Out Directory Path and Filename Suffixes
Removing New Lines and Return Lines from Text Files
Have you ever head of TR in Linux?
Inverting or Reversing Grep Matches
Strip Out Non-Directory Path from Filename
Removing Spaces from Filenames
Removing Blank Lines using Sed Or Grep
50 Quick Linux Command Tips Part 4
Subscription
Categories
- HowTos (612)
- Linux Devices (40)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
▼
2008
(2301)
-
▼
February
(25)
- HowTo: Extract Lines That Started With Matching St...
- HowTo: Delete All Thumbs.db Recursively
- HowTo: Handy Linux Network Diagnostic Tool
- HowTo: Display Lines That Starts With A Given String
- HowTo: Find And Count JPG Files Recursively
- HowTo: Do Awk with Loop
- HowTo: Strip Out First Word of Line from Text Files
- HowTo: Highlight Matching Grep Results
- HowTo: GNOME Commander File Manager
- HowTo: Install Plone CMS on Fedora
- HowTo: Thumbnail A Website From Linux Command Term...
- HowTo: Advanced Two-Pane File Manager
- HowTo: Two-Pane GUI File Manager
- Slash Proc - File System Utilities
- HowTo: Drop Down Linux Terminal Console
- HowTo: Image Magics with ImageMagick
- HowTo: Convert JPG Image Files to MPG Video Files
- HowTo: Alternative Way to Convert GIF to PNG
- HowTo: Lock X While Root With ScreenSaver
- HowTo: Encrypted Bandwidth-Efficient Linux Backup ...
- HowTo: Install Java IcedTea on Fedora 8
- HowTo: Simultaneous Install of Sun Java and Java I...
- HowTo: Install K9Copy on Fedora
- HowTo: More of Fedora Themes Package
- HowTo: European Language Fonts Installation on Fedora
-
▼
February
(25)
Sunday, February 24, 2008
HowTo: Strip Out First Word of Line from Text Files
Subscribe to:
Post Comments (Atom)
ILoveTux - howtos and news | About | Contact | TOS | Policy
0 comments:
Post a Comment