![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| creating a new profile from command line | cleansing_flame | OS X (Apple) | 2 | 12-03-2007 06:57 PM |
| making sure a command line paramter is a number | rcunn87 | Shell Programming and Scripting | 3 | 07-13-2006 07:36 AM |
| Creating a line for printing | jhansrod | Shell Programming and Scripting | 3 | 06-17-2005 02:38 AM |
| Making multi line output appear on one line | djsal | Shell Programming and Scripting | 1 | 10-07-2004 03:21 PM |
| Making Emacs to show line number | saurya_s | UNIX for Dummies Questions & Answers | 9 | 01-28-2004 10:32 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
creating conditions for making a new line?
Basically I want to change this:
a:b c:d:e f:g h:i:j k:l into a:b c d:e f:g h i:j k:l so like if there is two :'s in one line making the first into a new line. If anyone knows how to do this I would be very appreciative! |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
awk 'BEGIN { FS=":"; OFS=":" }
NF == 3 { printf "%s\n%s:%s\n", $1, $2, $3 }
NF != 3 { print }
' myfile
|
|
#3
|
||||
|
||||
|
Code:
awk 'NF==3?sub(/:/,RS):1' FS=: file or: Code:
sed '/:.*:/{s/:/\
/;}' file
|
|
#4
|
|||
|
|||
|
[quote=radoulov;302179620]
Code:
awk 'NF==3?sub(/:/,RS):1' FS=: file This is kind of working but it is sometimes deleting the second field rather than just creating a new line. |
|
#5
|
||||
|
||||
|
Could you please post the input that causes this behaviour?
Thank you! |
|
#6
|
|||
|
|||
|
Code:
sed '/:.*:/{s/:/\
/;}' file
I am using Putty and it wont perform this command. It is returning this reply: -bash-2.05b$ sed '/:.*:/{s/:/\/;}' ./assignment1/question3/a.txt sed: -e expression #1, char 15: Unterminated `s' command Do you know why? Am I typing the command wrong? |
|
#7
|
||||
|
||||
|
Quote:
Is this a homework? |
||||
| Google The UNIX and Linux Forums |
| Tags |
| solaris |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|