filter the string from a file ??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting filter the string from a file ??
# 8  
Old 09-17-2007
Lightbulb

Quote:
Originally Posted by SanjayLinux
Varun,
Try this one !!
cut -d ' ' -f 2 <file_name>|cut -c1-7

I dun't have any Linux/Unix system with me right now, so please check the syntex.

Thanks
Good try....But then tell me what will you do when the numeric length varies that means it could be of sometimes 7 characters, sometimes more then 7 characters and sometimes less then that. At that time your given option would fail, because immediately the numeric string there is a character attached, presently its 'c'.
inode 1138932c(mqsiadm)
inode 1257904c(mqsiadm)

Now tell me !!
Smilie
# 9  
Old 09-17-2007
Computer

Quote:
Originally Posted by vino
Perhaps,
Code:
[~]$ 
echo "inode 1138932c(mqsiadm)
inode 1257904c(mqsiadm)" | tr -dc "[:digit:]\n"
1138932
1257904
[~]$



Hey,
Thanks buddy, thats what I have been looking for !!
Smilie
# 10  
Old 09-17-2007
Smilie As well I told you that currently I dun have any *NIX box with.
There is one logic in my mind

After the Filter we can use "c" as a delimeter and then cut the firt Filed.
Try It !!

cut -d ' ' -f 2 <file_name>|cut -d 'c' -f 1


~~~Sanjay~~~
# 11  
Old 09-17-2007
Quote:
Originally Posted by SanjayLinux
Smilie As well I told you that currently I dun have any *NIX box with.
There is one logic in my mind

After the Filter we can use "c" as a delimeter and then cut the firt Filed.
Try It !!

cut -d ' ' -f 2 <file_name>|cut -d 'c' -f 1


~~~Sanjay~~~
Hey,

But what then if even the delimiter is other then c, because i am getting variable input into the file !! Can you place more then 1 delimiters then ??

Anyways as you don't have unix comp. now in front of you, leave it as of now, i got the o/p.

Thanks buddy !!Smilie
# 12  
Old 09-17-2007
try this one!!!!

Hi,
I think think this is ok.

Code:
echo inode 1138932c | sed 's/[a-z,A-Z]//g'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to filter string between specific string in ksh

My argument has data as below. 10.9.9.85 -rwxr-xr-x user1 2019-10-15 17:40 /app/scripts/testingscr5.scr 127869538 -rwxr-xr-x user1 2019-10-15 17:40 /app/scripts/testingscr56scr 127869538 ....... (note all these between lines will start with hyphen '-' ) -rwxr-xr-x user1 2019-10-15 17:40... (3 Replies)
Discussion started by: mohtashims
3 Replies

2. Shell Programming and Scripting

Shell script to filter records in a zip file that contains matching columns from another file

Not sure if this is the correct forum for this question. I have two files. file1.zip, file2 Input: file1.zip col1, col2 , col3 a , b , 0:0:0:0:0:c436:9346:d40b x, y, 0:0:0:0:0:880:39f9:c9a7 m, n , 0:0:0:0:0:80c7:9161:fe00 file2.txt col1 c4:36:93:46:d4:0b... (1 Reply)
Discussion started by: anil.v
1 Replies

3. UNIX for Dummies Questions & Answers

Filter records in a huge text file from a filter text file

Hi Folks, I have a text file with lots of rows with duplicates in the first column, i want to filter out records based on filter columns in a different filter text file. bash scripting is what i need. Data.txt Name OrderID Quantity Sam 123 300 Jay 342 498 Kev 78 2500 Sam 420 50 Vic 10... (3 Replies)
Discussion started by: tech_frk
3 Replies

4. Shell Programming and Scripting

Shell Script (ksh) - SQLPlus query filter using a string variable

Using ksh, I am using SQLPlus to execute a query with a filter using a string variable. REPO_DB=DEV1 FOLDER_NM='U_nmalencia' FOLDER_CHECK=$(sqlplus -s /nolog <<EOF CONNECT user/pswd_select@${REPO_DB} set echo off heading off feedback off select subj_name from subject where... (5 Replies)
Discussion started by: nkm0brm
5 Replies

5. Shell Programming and Scripting

Perl script to filter the string

Hi folks, I have a log file with the lines in the below format. Jul 1 23:00:51 10.212.3.251 SS: %SYS-7-CLI_SCHEDULE: some error occured I want to split the line based on the " %SYS-7-CLI_SCHEDULE: " value. The criteria is the should store the word that starts with % i.e., ... (1 Reply)
Discussion started by: scriptscript
1 Replies

6. UNIX for Dummies Questions & Answers

Help me to filter a file

I want to view a file ignoring mutilple comment line (/*....*/). Please help me on this. Advance thanks.:b: (5 Replies)
Discussion started by: Pradipta Kumar
5 Replies

7. UNIX for Dummies Questions & Answers

Filter a particular string

Hi, I have a long log file. Out of which I want to filter particular occurrences where APC=4-033-0. Please help how it can be done. Input : +++ ELEMENT 12-05-27 23:15:06 CC 3482 #040185 > REPT APB TPE=C7NTL SM=22 OPC=4-003-7 APC=4-033-4 inaccessible END OF REPORT #040185 ++- ... (7 Replies)
Discussion started by: vanand420
7 Replies

8. Shell Programming and Scripting

Filter a .kml file (xml) with data set from text file

I have a .kml file. So I want filter the .kml to get only the tags that have this numeric codes that they are in a text file 11951 11952 74014 11964 11965 11969 11970 11971 11972 60149 74018 74023 86378 11976 11980 11983 11984 11987 (5 Replies)
Discussion started by: pcoj33
5 Replies

9. Shell Programming and Scripting

Sed filter words from string

I have following string in a variable: str="sstring garbage adfsdf tab.col1 lkad rjfj tab2.col2 adja tab2.col4 garbage" I want to filter "word.word" pattern from it. I assume the pattern won't occur in start or end of the string. Output shoud be: tab.col1 tab2.col2 tab2.col4 Can this be... (7 Replies)
Discussion started by: amicon007
7 Replies

10. Shell Programming and Scripting

File filter

Hi Everyone , have a nice i would need a little help on this i have file which contains blocks such as given below <hgsdp:msisdn=923228719047,loc; HLR SUBSCRIBER DATA SUBSCRIBER IDENTITY MSISDN IMSI STATE AUTHD 923228719047 410072110070614 CONNECTED ... (3 Replies)
Discussion started by: Dastard
3 Replies
Login or Register to Ask a Question