![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| check line by line in a file | loperam | Shell Programming and Scripting | 6 | 11-04-2008 12:24 AM |
| how to check by line | ooilinlove | Shell Programming and Scripting | 4 | 08-18-2008 10:35 AM |
| Check last line with gawk? | sjf | Shell Programming and Scripting | 3 | 10-04-2006 02:20 AM |
| Dynamic includes file for tar command | kadishmj | UNIX for Dummies Questions & Answers | 1 | 03-09-2005 06:48 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
..to check if a line includes a subline..?
What would be the best way to check if a particular line (in variable) has an another line (more than 1 char)?
I understand it could be done with 'grep', 'sad', 'awk', by parameter expansion, but all these seems to me havy, worldy, not elegant and overhead in processing For so common task I would expect something from shell, maybe, close to: Code:
>a="string with piece to search"
>${a??"piece"} && echo "the string has a searched substring" || echo "not found"
But I do not know anything like that. - Maybe I just do not know? Otherwise, what would be your best aproach to perform that simple action? Thank you! |
|
||||
|
Thank you, it is good: last 2 are pretty nice, the 'case' is interesting, too, but little wordy.
Neither one way did come to my mind. In my bash the match operator works; so it is best: Code:
> a="string with piece to search" > [[ $a =~ piece ]] && ec da || ec net da > |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| shell script, shell scripting, unix scripting, unix scripting basics |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|