How to cut string and find missing pattern?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to cut string and find missing pattern?
# 8  
Old 05-01-2012
If AWK it was working that way, END section would be useless. Now you didn't answer my question: did you try my code?
# 9  
Old 05-01-2012
dear bartus11 ,

i have tried urs suggested solution ....after giving the command its giving the output list from 01 to 24 but missing pattern is from 13 to 24


the command i am giving is mentioned in above post

thanks for reply.
# 10  
Old 05-01-2012
What operating system are you using?
# 11  
Old 05-01-2012
dear all,

i have opened my file in vi editor

its showing my file string as

Code:
^[[00mqm12010512.^[[00m^M


but after opening with cat its showing
Code:
qm12010512.

will it create any problem in execution of command suggested above

if its so plz suggest something.
# 12  
Old 05-01-2012
Yes, it means that you have Windows line ending characters there. Run
Code:
dos2unix filename

before running the AWK code.
# 13  
Old 05-01-2012
My O/S is HP unix and shell is sbin/sh

and i have tried this command its showing the following error
Code:
dos2unix file.txt
sh: dos2unix:  not found.

i have to do this with script
hence plz suggest in that way

thanks for quick reply
# 14  
Old 05-01-2012
remove those characters by using the below command.

Code:
perl -pe 's/\033\[[^m]*m//g' < input.txt > output.txt

now open the output.txt and see, whether those weired characters are there or not

---------- Post updated at 05:23 PM ---------- Previous update was at 05:22 PM ----------

After that, try the below

Code:
$ for i in {01..24}; do grep "^qm$i" output.txt > /dev/null 2>&1 || echo "qm"$i"21412"; done

This User Gave Thanks to itkamaraj For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to find string based on pattern and search for its corresponding rows in column

Experts, Need your support for this awk script. we have only one input file, all these column 1 and column 2 are in same file and have to do lookup for values in one file(column1 and column2) but output we need in another file Need to grep row whose string contains 9K from column 1. When found... (6 Replies)
Discussion started by: as7951
6 Replies

2. Shell Programming and Scripting

awk to insert missing string based on pattern in file

Using the file below, which will always have the first indicated by the digit after the - and last id in it, indicated by the digit after the -, I am trying to use awk to print the missing line or lines in file following the pattern of the previous line. For example, in the file below the next... (4 Replies)
Discussion started by: cmccabe
4 Replies

3. Shell Programming and Scripting

How can I use find command to search string/pattern in a file recursively?

Hi, How can I use find command to search string/pattern in a file recursively? What I tried: find . -type f -exec cat {} | grep "make" \; Output: grep: find: ;: No such file or directory missing argument to `-exec' And this: find . -type f -exec cat {} \; -exec grep "make" {} \;... (12 Replies)
Discussion started by: cola
12 Replies

4. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies

5. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

6. Shell Programming and Scripting

find: missing argument to `-exec' while redirecting using find in perl

Hi Friends, Please help me to sort out this problem, I am running this in centos o/s and whenever I run this script I am getting "find: missing argument to `-exec' " but when I run the same code in the command line I didn't find any problem. I am using perl script to run this ... (2 Replies)
Discussion started by: ramkumarselvam
2 Replies

7. Shell Programming and Scripting

How do i find the first number in each line and insert dummy string into the missing columns?

Hi, I have one input file with the following content: MY_inpfile.txt Aname1 Cname1 Cname2 1808 5 Aname2 Cname1 1802 47 Bname1 ? 1819 22 Bname2 Cname1 1784 11 Bname3 1817 9 Zname1 Cname1 1805 59 Zname2 Cname1 Cname2 Cname3 1797 27 Every line in my input file have a 4 digit... (5 Replies)
Discussion started by: Szaffy
5 Replies

8. Shell Programming and Scripting

Find missing string with bash

If I have a file called file A with a list of filenames. How do I find all the filenames in file A that aren't contained in file B? I want to use bash scripting. (2 Replies)
Discussion started by: locoroco
2 Replies

9. UNIX for Dummies Questions & Answers

cmd sequence to find & cut out a specific string

A developer of mine has this requirement - I couldn't tell her quickly how to do it with UNIX commands or a quick script so she's writing a quick program to do it - but that got my curiousity up and thought I'd ask here for advice. In a text file, there are some records (about half of them)... (4 Replies)
Discussion started by: LisaS
4 Replies

10. Shell Programming and Scripting

cut subsrting from string depending on pattern

Dears, i'm glad to be a member of this big UNIXer's group :( ,hoping to be one of'm. my question: how i get the subsrting ahmad "from" the string ".ahmad." for example ?? Thank you all. (5 Replies)
Discussion started by: Muslem_it
5 Replies
Login or Register to Ask a Question