LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Containers
User Name
Password
Linux - Containers This forum is for the discussion of all topics relating to Linux containers. Docker, LXC, LXD, runC, containerd, CoreOS, Kubernetes, Mesos, rkt, and all other Linux container platforms are welcome.

Notices


Reply
  Search this Thread
Old 04-08-2018, 05:02 AM   #1
deep_kol
LQ Newbie
 
Registered: Jul 2017
Posts: 4

Rep: Reputation: Disabled
Identify the special characters in file in unix


Hi Friends ,
Need your help to solve this issue . Need to identify the special characters in a file . I tried the below way .

Step 1 :
Create data file test.txt

Quote:

105712848,161,20180115,20180331,552,abc
105712848,160,20180115,20180331,240,abc 2018
104231840,475,20180115,20180331,192,xyz 2018
104231840,475,20180115,20180331,192,xyz 2018@

Steps 2 : run the syntax
Quote:
grep -v "^[A-Za-z0-9,]*$" test.txt
it should give you the below record ,bcz it has a special character @
104231840,475,20180115,20180331,192,Salt 2018

But it does not . Can you please let me know what is wrong in this
 
Old 04-08-2018, 05:29 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 11,350

Rep: Reputation: 3418Reputation: 3418Reputation: 3418Reputation: 3418Reputation: 3418Reputation: 3418Reputation: 3418Reputation: 3418Reputation: 3418Reputation: 3418Reputation: 3418
probably you missed some chars, like space (from your regexp).
 
Old 04-08-2018, 02:49 PM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Slackware 14.2 / Slackware 14.2 current / Manjaro / Parrot
Posts: 6,891

Rep: Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394
thats a tricky one,

Code:
$ egrep '[0-9A-z]@' findchars
104231840,475,20180115,20180331,192,xyz 2018@
might not be the exact what you're looking for though. could just look for the special char.
Code:
$ egrep '@' findchars
104231840,475,20180115,20180331,192,xyz 2018@
all the other are canceled out, no need to even look for them. just set it up to look for the special char(s) you're looking for.
 
Old 04-08-2018, 05:28 PM   #4
deep_kol
LQ Newbie
 
Registered: Jul 2017
Posts: 4

Original Poster
Rep: Reputation: Disabled
This way i have to identify all the special characters and hard code them .It will not fulfill my requirement.
Quote:
$ egrep '@' findchars
104231840,475,20180115,20180331,192,xyz 2018@
Do not understand why the below syntax does not give the correct result .

Quote:
grep -v "^[A-Za-z0-9,]*$" test.txt
 
Old 04-08-2018, 05:44 PM   #5
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Slackware 14.2 / Slackware 14.2 current / Manjaro / Parrot
Posts: 6,891

Rep: Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394
Quote:
Originally Posted by deep_kol View Post
This way i have to identify all the special characters and hard code them .It will not fulfill my requirement.

Code:
grep -v "^[A-Za-z0-9,]*$" test.txt
Do not understand why the below syntax does not give the correct result .
did you notice you're identifying all of the other characters and not getting your desired results? that is all I know about that one. let research it?
 
Old 04-09-2018, 01:33 AM   #6
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 11,350

Rep: Reputation: 3418Reputation: 3418Reputation: 3418Reputation: 3418Reputation: 3418Reputation: 3418Reputation: 3418Reputation: 3418Reputation: 3418Reputation: 3418Reputation: 3418
Quote:
Originally Posted by deep_kol View Post
Do not understand why the below syntax does not give the correct result .
Repeating the same question will not help. Would be nice to explain what should be the correct result, what did you get instead. Also did you check post #2?
 
Old 04-23-2018, 10:50 AM   #7
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Slackware 14.2 / Slackware 14.2 current / Manjaro / Parrot
Posts: 6,891

Rep: Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394Reputation: 1394
I think your best bet is to work on the basics. First figure out what a pattern is, or what does a pattern consist of,
or what qualifications does something have to have in order to be defined as a pattern? Whence you figure that out,
then move onto the next step, finding a program that searches for patterns and learn how to use it to do just that.
If you have any difficulties arise then seek guidance for same.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
copy file whose file name containing special characters from Linux to Window phuong Linux - Newbie 4 02-28-2012 10:52 AM
[SOLVED] $@ >> file with special characters dmafcoi Linux - Newbie 15 05-27-2010 03:37 PM
removing file with special characters rsashok Linux - General 4 02-09-2010 04:08 PM
Special characters in file names Jinouchi Linux - Newbie 7 07-25-2009 11:48 AM
How to remove file with name containing only special characters abhisheknayak Linux - Newbie 5 07-04-2008 10:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Containers

All times are GMT -5. The time now is 12:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration