Breaking line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Breaking line
# 1  
Old 09-18-2008
Breaking line

My input file is like

USER_WORK.ABC
USER_WORK.DEF


I want output file like

ABC
DEF
# 2  
Old 09-18-2008
Code:
#  sed 's/.*\.//g' infile
ABC
DEF

or

#  awk -F"." '{print $2}' infile
ABC
DEF

or

#  cut -d. -f2 infile
ABC
DEF

...

Smilie
# 3  
Old 09-18-2008
hi Tytalus,

can u pls explain how this works...?



sed 's/.*\.//g' infile
# 4  
Old 09-18-2008
Edit: Tytalus was faster, nvm.

Last edited by zaxxon; 09-18-2008 at 09:19 AM..
# 5  
Old 09-18-2008
Quote:
can u pls explain how this works...?
sed 's/.*\.//g' infile

yeah - sure:
Code:
sed '
s        # substitute
/
.*\.      # anything that matches this pattern - i.e any number of chars followed by a .
//       # with this pattern i.e. nothing - effectively deletes everything up to the .
g'       # globally 
infile

HTH
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Breaking a pipe

Here's my code - for File in "${Files}"; do uuencode "${File}" "$(basename ${File} 2>&-)" 2>&-; done | mailx -s "subject" "a@b.c" Now I want to know if there a way to *not* send an email if the "Files" variables turns out to be blank. Any suggestions? Also, just to clarify, I... (4 Replies)
Discussion started by: nexional
4 Replies

2. Shell Programming and Scripting

Breaking out of an if statement

i have a nested if statement. i need to check for a condition (highlighted in red below). if condition is true, i need the if statement to break out of the statement and then return to the if statement section i have highlighted in blue. is this possible? if ; then #return here ... (6 Replies)
Discussion started by: SkySmart
6 Replies

3. UNIX for Dummies Questions & Answers

Breaking up at the second occurrence

hi, My input is: 123 1234|123|123|123 123|123|456 123|123|12 12 Expected output is: 123 1234|123 123|123 123|123 456 123|123 12 (1 Reply)
Discussion started by: pandeesh
1 Replies

4. Shell Programming and Scripting

'for LINE in $(cat file)' breaking at spaces, not just newlines

Hello. I'm making a (hopefully) simple shell script xml parser that outputs a file I can grep for information. I am writing it because I have yet to find a command line utility that can do this. If you know of one, please just stop now and tell me about it. Even better would be one I can input... (10 Replies)
Discussion started by: natedawg1013
10 Replies

5. Shell Programming and Scripting

breaking for loop

Dear Friends, Here I need your guidance once again. I have for loop which check all files in a folder for a particular string. If the string is found in a file it returns value other than 0 else returns 0 value in variable t2. At times the string which we are looking for is in first file... (1 Reply)
Discussion started by: anushree.a
1 Replies

6. Shell Programming and Scripting

Breaking out of loop

I have a main script with while loop having for loop inside. Again in for loop based on if condition few functions will be called. So when a function is called for certain condition it should come out from the main for loop and should continue with while loop. Let me explain with example here: I... (6 Replies)
Discussion started by: vpv0002
6 Replies

7. Shell Programming and Scripting

Breaking up a file

Hi, I have a file that looks like this - lets call it fileA >hhm2 IIIIIIIIILLLLLLLMMMMMMMMMNNNNNNNNNNGGGGGGHHHHHHHH >hhm4 OOOOOKKKKKKKKMMMMMHHHHHLLLLLLLLWWWWWWWWWWW >hhm9 OOOOOOOIIIIIIIIIKKKKKKKKKMMMMMHHHHHHHHHHHLLLLLLLLLL So the file is pretty straight forward. The name is indicated... (2 Replies)
Discussion started by: phil_heath
2 Replies

8. Shell Programming and Scripting

Breaking out of a pipe

I have the following command in a Bash shell script: who | grep -w $1 | some other commands If grep fails, an error message is displayed. How do I test if grep fails and still be able to pipe it's output to the rest of the commands? I have the following solution: a=`who | grep -w $1`... (3 Replies)
Discussion started by: oinkl
3 Replies

9. Shell Programming and Scripting

Breaking up of a fixe width line in unix

Hi, I need some help with breaking up a given line based on 'fixed width' file. Something like this: After the breaking up, I need to have this output format... First line should have the first 134 characters. Starting from second line, I should have one line every 61... (3 Replies)
Discussion started by: rputtagunta
3 Replies
Login or Register to Ask a Question