- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- cut content in a file
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2004 01:20 PM
03-18-2004 01:20 PM
# cat abc.txt
79 10 1 "S036593" "SAND_A01" "sa110c" 02/11/04 0 0
6 1 2 "S036553" "VIOL_A01" "V0470C" 02/26/04 0 0
how can I cut the date column out to a file ?
I want to the result like that:
02/11/04
02/26/04
thx in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2004 01:28 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2004 01:33 PM
03-18-2004 01:33 PM
Re: cut content in a file
cat abc.txt | cut -f7
cat abc.txt | sed 's|.*\(../../..\).*|\1|'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2004 02:36 PM
03-18-2004 02:36 PM
Re: cut content in a file
6 1 2 "S03 553" "VIOL_A01" "V0470C" 02/26/04 0 0
Is it, as per Curt's second solution two chars, a slash, two chars, an other slash and two more chars? That rule will merrily trigger on: "blah bl/ah/ blah"
returning "bl/ah/ b"
Or do you need a tight rule like the following regulare expression in perl:
perl -p -e '$_="$1\n" if (/ (\d\d\/\d\d\/\d\d) /)' < abc.txt.
That looks for a space, two digits, a slash (escaped), two more digits, a slash, two more digits and a space. If it sees that, remember (the parentheses) the part between the spaces in $1 and copy to the default output string ($_) terminated by a \n.
'course that rule will not fire on 14/3/04 whether you consider that a valid date or not.
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2004 03:49 PM
03-18-2004 03:49 PM
Re: cut content in a file
cut -d " " -f7 abc.txt > out_file
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2004 03:56 PM
03-18-2004 03:56 PM
Re: cut content in a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2004 04:36 PM
03-18-2004 04:36 PM
Re: cut content in a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2004 03:36 AM
03-20-2004 03:36 AM
Re: cut content in a file
If you can be sure that the date is always in the 7th field, use
awk '{print $7}' abc.txt
But the following seems better:
awk '{print $(NF-2)}' abc.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2004 07:55 PM
03-22-2004 07:55 PM
Re: cut content in a file
You could try this though its a little long winded and involves creating a temp file to disk.
sed/ /~/g abc.txt > abc.tmp
date=`pg abc.tmp | cut -f 7 -d "~"`
awk may be a better option as previously posted!
Keith