finding characters with new line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting finding characters with new line
# 8  
Old 10-28-2009
Quote:
Originally Posted by kinny
gawk not found Smilie

any other plan

Are you on Solaris?

Code:
nawk ' ... '

# 9  
Old 10-28-2009
Hi Johnnson ,
That worked with a small modification .
Can you explain what happens in this command

---------- Post updated at 04:40 AM ---------- Previous update was at 03:30 AM ----------

Hi Johnson,
This doesnt work. This is my command
nawk -v str="dev" ' { RS = "||"; FS = "-" } $0 ~ str { print $2}' sample.txt gives me
reeeec
and removes the new line. Any help is much appreciated
# 10  
Old 10-28-2009
any help for this wil also help me..
# 11  
Old 10-28-2009
Use nawk or /usr/xpg4/bin/awk on Solaris.

Code:
awk '
!/\|/{getline s;$0 = $0 FS s}
{ $1=$NF""
  gsub("\|\|","")
  sub("^ ","")
  sub("- ","")
  print
}' file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding first 6 characters

Hi , I'm using KSH88 I tried the following example to get the last 6 characters from a string echo 'abcdefghids' | sed 's/.*\(.\{6\}\)$/\1/' What chages i need to do to get the first 6 characters from the string my desired output should be abcdef Thank you (6 Replies)
Discussion started by: smile689
6 Replies

2. Shell Programming and Scripting

Finding distinct characters from flat file

Hi....I need one help.... I'm having a files which is having the data as follows... a b c c d d d e f Now I need to find out distinct characters from this file and the output should be as follows - a b c d e f Can you please help me on this? I'm using KSH script. (18 Replies)
Discussion started by: Krishanu Saha
18 Replies

3. Shell Programming and Scripting

Finding Strings between 2 characters in a file

Hi All, Assuming i have got a file test.dat which has contains as follows: Unix = abc def fgt jug 111 2222 3333 Linux = gggg pppp qqq C# = ccc ffff llll I would like to traverse through the file, get the 1st occurance of "=" and then need to get the sting... (22 Replies)
Discussion started by: rtagarra
22 Replies

4. UNIX for Dummies Questions & Answers

Finding specific series of strings or characters

After spending sometime playing around with my script I just cannot get it to do what I want. So I decided to ask. My file looks something like this: I am using the following code to extract sequences that contain dashes awk '/^>/{id=$0;next}{if (match($1,"-")) print id "\n" $0}' infile ... (17 Replies)
Discussion started by: Xterra
17 Replies

5. UNIX for Dummies Questions & Answers

finding and moving files based on the last three numerical characters in the filename

Hi, I have a series of files (upwards of 500) the filename format is as follows CC10-1234P1999.WGS84.p190, all in one directory. Now the last three numeric characters, in this case 999, can be anything from 001 to 999. I need to move some of them to a seperate directory, the ones I need to... (5 Replies)
Discussion started by: roche.j.mike
5 Replies

6. Shell Programming and Scripting

Finding File Names Ending In 3 Random Numerical Characters

Hi, I have a series of files (upwards of 500) the filename format is as follows CC10-1234P1999.WGS84.p190 each of this files is in a directory named for the file but excluding the extension. Now the last three numeric characters, in this case 999, can be anything from 001 to 999, I need to... (3 Replies)
Discussion started by: roche.j.mike
3 Replies

7. Shell Programming and Scripting

finding junk characters

Hi, Is there anyway to find the junk characters in a file.Consider the file has data as given below: 123|abc^M|Doctor^C #record 1 234|def|Med #record 2 345|dfg^C|Wrong^V #record 3 The junk characters are highlighted and this is a pipe delimited file. Is there anyway to... (20 Replies)
Discussion started by: ashwin3086
20 Replies

8. UNIX for Dummies Questions & Answers

Finding absolute pathnames longer than 100 characters

Please help. This simple problem is really stumping me. Is there are way to find absolute pathnames for all files on your system that are longer than 100 characters? I'm using bash shell to attempt it, but have come up with nothing so far. I appreciate any help offered. Nauty (2 Replies)
Discussion started by: nauty
2 Replies

9. UNIX for Dummies Questions & Answers

Unix Command for finding Nul Characters

Hi Folks, I have this windowed applescript application I use for sending out emails, it uses the Postfix daemon buit into my Mac Os X box, and a 3 SMTP servers (out of hundreds I send emails to) were refusing my messages replying "host smtp2.braspress.com.br said: 550 Requested action not... (2 Replies)
Discussion started by: fundidor
2 Replies

10. UNIX for Dummies Questions & Answers

finding exact characters

I want to grep from a file an exact character match. I tried grep -c "$a $b" $file where a=6 and b=2 the problem is that I get: 6 2 and 6 20 I just need a count of the occurrence. I'm using the Bourne shell. I've also tried grep -c '$a $b' $file; not sure how to do this - any suggestions? (3 Replies)
Discussion started by: jrdnoland1
3 Replies
Login or Register to Ask a Question