Search the pattern and copy in to the file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Search the pattern and copy in to the file
# 8  
Old 04-09-2012
thanks for reply balajesuri
this command is execited partially .it is printing the hex values and after if any data is there means that also it is prinint...for eg:
Code:
0x1233jkfhgjfhgajk;gha 0xacdd
0xccc jhfjkhsd
0x456 jkhdfjhjkafh

like this....

Last edited by Scrutinizer; 04-09-2012 at 04:12 AM.. Reason: code tags
# 9  
Old 04-09-2012
Hello,

Per our forum rules, all users must write in English, use semi-formal or formal English language and style, and correct spelling errors.

The reason for this is that most software and operating systems are written in English and these are software related technical forums.

In addition, nearly 95% of all visitors to this site come here because they are referred by a search engine. In order for future searches on your post (with answers) to work well, you need to spell correctly!

So, as a benefit and courtesy to current and future knowledge seekers, please be careful with your language, check your spelling and correct your spelling errors. You might receive a forum infraction if you don't pay attention to this.

Also, do not write in cyberpunk or abbreviated chat style under any circumstances and do not use profanity. This is not a chat room, it is a formal knowledge base to serve you and everyone, of all ages and cultural backgrounds.

Thanks!

The UNIX and Linux Forums
# 10  
Old 04-09-2012
thanks balajesuri
it is working partially..what it is giving output is like
0x1233jkfhgjfhgajk
0xccc jhfjkhsd
0x456 jkhdfjhjkafh
i dnt want extra other than hex data..wl you plz help me

Moderator's Comments:
Mod Comment

Last edited by Scrutinizer; 04-09-2012 at 05:23 AM..
# 11  
Old 04-09-2012
I don't understand your requirement. Please post the desired output (something like.. "this is how my output should look like") and a brief description of the logic that goes behind in arriving at desired output from given input.
# 12  
Old 04-09-2012
there is one file caled hex.txt..it contains is
Code:
abch 0x1234 hjhhjgfdsdjk 0x4567
iam so 0xfff happy y
bcoz iam learning shell
and iam using 0xabcd
0xcdef unix forums...

now i want to search the hex values and copy into the hexc.txt...file...so atlast hexc.txt file should contains oly hex data that is
Code:
0x1234
0x4567
0xfff
0xabcd
0xcdef

this is the output iam expecting in hexc.txt

Moderator's Comments:
Mod Comment

Last edited by Scrutinizer; 04-09-2012 at 07:35 AM.. Reason: code tags
# 13  
Old 04-09-2012
Code:
$ perl -lane 'foreach(@F){print $_ if $_=~/^0x/}' input.txt
0x1234
0x4567
0xfff
0xabcd
0xcdef

---------- Post updated at 04:15 PM ---------- Previous update was at 04:14 PM ----------

Code:
$ awk '{for(i=1;i<=NF;i++)if($i~/^0x/)print $i}' input.txt 
0x1234
0x4567
0xfff
0xabcd
0xcdef

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Grep/awk using a begin search pattern and end search pattern

I have this fileA TEST FILE ABC this file contains ABC; TEST FILE DGHT this file contains DGHT; TEST FILE 123 this file contains ABC, this file contains DEF, this file contains XYZ, this file contains KLM ; I want to have a fileZ that has only (begin search pattern for will be... (2 Replies)
Discussion started by: vbabz
2 Replies

2. UNIX for Beginners Questions & Answers

Copy pattern inside the file

Hi all, I have files and have a missing record. I need copy the existing record and mark those values up. For example in the below file 11048 is missing. I need to copy 22001 and copy those create the values for 11048. I have 120 set of files and I need to do that on all files. Note the... (8 Replies)
Discussion started by: arunkumar_mca
8 Replies

3. Shell Programming and Scripting

How to use sed to search a particular pattern in a file backward after a pattern is matched.?

Hi, I have two files file1.txt and file2.txt. Please see the attachments. In file2.txt (which actually is a diff output between two versions of file1.txt.), I extract the pattern corresponding to 1172c1172. Now ,In file1.txt I have to search for this pattern 1172c1172 and if found, I have to... (9 Replies)
Discussion started by: saurabh kumar
9 Replies

4. Shell Programming and Scripting

Search for a pattern in a String file and count the occurance of each pattern

I am trying to search a file for a patterns ERR- in a file and return a count for each of the error reported Input file is a free flowing file without any format example of output ERR-00001=5 .... ERR-01010=10 ..... ERR-99999=10 (4 Replies)
Discussion started by: swayam123
4 Replies

5. Shell Programming and Scripting

search a word and copy the file

Hi need help with a script or command My requirement is - I need to do a "ls -ltr tcserver*.syslog" files in /tmp, direct the output to a file ls -ltr tcserv*.syslog | grep "Jan 31" | awk '{printf "\n" $9}' > jandat.logs -Then open each file in above list and search for string/word,... (4 Replies)
Discussion started by: karghum
4 Replies

6. Shell Programming and Scripting

sed help - search/copy from one file and search/paste to another

I am a newbie and would like some help with the following - Trying to search fileA for a string similar to - AS11000022010 30.4 31.7 43.7 53.8 60.5 71.1 75.2 74.7 66.9 56.6 42.7 32.5 53.3 I then want to replace that string with a string from fileB - ... (5 Replies)
Discussion started by: ncwxpanther
5 Replies

7. Shell Programming and Scripting

Search and copy to a new file-Help

Hi All, server16.na.in.com UNKNOWN ftpuser "CWD" dms-imrm/Delasco_Invoices_DayForward_Scan" 250 - server16.na.in.com UNKNOWN ftpuser "PWD" 257 - server16.na.in.com UNKNOWN ftpuser "CWD Private" 250 - server16.na.in.com UNKNOWN ftpuser "PWD" 257 - server16.na.in.com UNKNOWN... (7 Replies)
Discussion started by: Tuxidow
7 Replies

8. UNIX for Dummies Questions & Answers

Shell script to search for text in a file and copy file

Compete noob question.... I need a script to search through a directory and find files containing text string abcde1234 for example and then copy that file with that text string to another directory help please :eek: (9 Replies)
Discussion started by: imeadows
9 Replies

9. UNIX for Advanced & Expert Users

File extension search and copy

Hi need to know if we can write a shell script to find files for a particular format;s ie both .csv and .txt in a particular folder and then copy them to a new folder on a dialy basis. Does anyone know how this can be accomplished? Thanks, Sandeep (20 Replies)
Discussion started by: bsandeep_80
20 Replies

10. Shell Programming and Scripting

Search file for pattern and grab some lines before pattern

I want to search a file for a string and then if the string is found I need the line that the string is on - but also the previous two lines from the file (that the pattern will not be found in) This is on solaris Can you help? (2 Replies)
Discussion started by: frustrated1
2 Replies
Login or Register to Ask a Question