Visit The New, Modern Unix Linux Community


What is meaning of given line?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers What is meaning of given line?
# 1  
What is meaning of given line?

Hello Guys,

I was study some links, where I was unable to understand below line, please enhance me these code.
Quote:
sed 's/\([a-z]*\) \1/\1/'
# 2  
Code:
sed 's/\([a-z]*\) \1/\1/'

is a basic (obsolete) regular expression, which replaces the first occurrence of zero or more lower case chars (lets call it PAT1) followed by a space followed by PAT1 again. In fact, it replaces the first space in every single line, as it matches PAT1 with the NULL (empty) string.
This User Gave Thanks to RudiC For This Post:
# 3  
Please give me example of above basic regular expression so that I can understand well.
# 4  
Hello Aditya,

Here are some examples for basic sed operations. Let's say we have an input file as follows.
Code:
cat check_pipie
1|John|32|US|
2|Matt|35|UK
3|Rex|36|EU|

Then some of the examples are as follows for sed with a little regular expresssions.
Code:
1- sed 's/|/\"/g' check_pipie
#### To subtitute string | with string "
 
2-  sed 's/^[^.]\{2\}//g' check_pipie
##### To remove 1st 2 characters in each line.
 
3- sed 's/[[:alpha:]]//g' check_pipie
##### To remove all alphabetic characters in file.
 
4- sed 's/\(..\)$//g' check_pipie
#### To remove last 2 characters in file.

Also following links may be helpful for you to understand sed more with some examples and details.

https://www.gnu.org/software/sed/man...pressions.html
Unix - Regular Expressions with SED
GNU Regular Expression Extensions - Gnulib Regex Module

Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #109
Difficulty: Easy
The Unix shell is the interface between the user and the kernel.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Meaning of $1^

Hello everyone, I'm looking for the meaning of this expression, as I don't understand it quite clearly : $1^ What do you think it could be? I thought either: - match lines starting with argument 1 but it should be ^$1 - turn line around : word becomes drow Thanks in advance for your... (4 Replies)
Discussion started by: bibelo
4 Replies

2. Shell Programming and Scripting

Meaning

Please let me know the meaning for the below statements in shell scripting. 1) exit -99 -------------------------------- 2) set prgdir = `pwd` set runFlag = runFlag:FALSE ------------------------------------- 3) if (-f $prgdir/maillst.eml) then set distEmail = `cat $prgdir/maillst.eml`... (1 Reply)
Discussion started by: lg123
1 Replies

3. UNIX for Dummies Questions & Answers

meaning of <<!

Hi all, I wanna know the meaning of the last word "<<! " sudo su - user <<! please help on this !!!! (1 Reply)
Discussion started by: sudharson
1 Replies

4. Shell Programming and Scripting

meaning of !*

can someone please tell what !* means in shell syntax. Regards, (3 Replies)
Discussion started by: busyboy
3 Replies

5. UNIX for Dummies Questions & Answers

what the meaning of #*

can some one please tell the meaning of the second statement i.e n=${m#*=} i couldnt get the meaning of the #*= 1.) m="mohit=/c/main/issue" echo $m result ----------- mohit=/c/main/issue 2.) n=${m#*=} echo $n RESULT ------- /c/main/issue (1 Reply)
Discussion started by: narang.mohit
1 Replies

6. Shell Programming and Scripting

Meaning of this line in script

Can anyone explain me the meaning of line #2 in these lines of shell script: if ; then ${EXPR} " ${MACTIONS } " : ".* ${ACTION} " >/dev/null 2>&1 || die "$USAGE" else Sorry in case this is a trivial thing (I am not an expert in this). (3 Replies)
Discussion started by: radiatejava
3 Replies

7. UNIX for Dummies Questions & Answers

Use and meaning of $*

Can someone explain the use and meaning of "$*" expression. (2 Replies)
Discussion started by: sinpeak
2 Replies

8. AIX

meaning of ${0%${0##*/}}

. ${0%${0##*/}}Script_Name if i issue this command, it is executing the script. can any one tell what is the meaning of ${0%${0##*/}} (7 Replies)
Discussion started by: nyelavarthy
7 Replies

9. Shell Programming and Scripting

Want to understand the meaning of the following line

HI All Please find the code below from a script called test.sh echo "Hello World" . test_common.lib get_info in the file test_common.lib i have the following contents get_info() { c_cnt=0; cm=""; echo "Inside get_info" } when i run the script test.sh ... (5 Replies)
Discussion started by: dhanamurthy
5 Replies

10. Shell Programming and Scripting

what is the meaning here?

#!/bin/sh $ORACLE_HOME/bin/sqlplus -S $orauserid/$orapasswd@$oradb << _TMP alter session set nls_date_format = 'YYYYMMDD HH24:MI'; set linesize 100 set pagesize 400 ok the above is part of a script..i just wanna know what does sqlplus -S means?? as in why we need to insert the -S behind? (2 Replies)
Discussion started by: forevercalz
2 Replies

Featured Tech Videos