matching pattern to end of line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting matching pattern to end of line
# 8  
Old 07-25-2012
Quote:
Originally Posted by ripat
Is not what I have posted. You must filter the output with /!/
Code:
 awk '/!/{gsub(/./," ",$1); print }' OFS=! FS=! radon3d_subs.f90
/: Event not found.

The problem was that when I captured the command in the history it chucked that thing out. Another reason against csh!!!

---------- Post updated at 06:04 AM ---------- Previous update was at 05:49 AM ----------

I have tried

Code:
grep "!" radon3d_subs.f90 | sed 's/.*\! //'

on the following

Code:
  !!
  !! SUB radon3d_temporal_fourier

  subroutine radon3d_temporal_fourier( tcube, fcube, c_dir )
  implicit none

  ! Arguments

  real, dimension(:,:,:), intent(in) :: tcube
  complex, dimension(:,:,:), intent(in) :: fcube
  character(len=*), intent(in) :: c_dir

  ! Local variables

  real, dimension(:), allocatable :: ft  ! stores a single trace
  real, dimension(:), allocatable :: tr  ! stores a single trace (extended to size of ft)

  ! IMPLEMENTATION ---------------------------------------------------------------------------------

  nt = size(tcube,1)
  nx = size(tcube,2)
  ny = size(tcube,3)
  nf = size(fcube,1)

  ! trace in the frequency domain
  allocate( ft(nf) )

  ! trace extended to size(ft)
  allocate( tr(nf) )

  !!> SELECT TRANSFORMATION DIRECTION

  select case ( c_dir(1:1) )

    !!> time to frequency
    case ('+')

      do iy = 1, ny

          do ix = 1, nx
              tr(nf) = 0.0  !!> ensures last sample is zero when nf > nt
              tr(1:nt) = (tcube(1:nt,ix,iy)
              ft = cfft(tr, '+')
              fcube(1:nf,ix,iy) = ft(1:nf)
          enddo

      enddo

    !!> frequency to time
    case ('-')

      do  iy = 1, ny

          do  ix = 1, nx
              ft(1:nf) = fcube(1:nf,ix,iy)
              tr = cfft(ft, '-')
              tcube(1:nt,ix,iy) = tr(1:nt)  !!> nt may be smaller than nt
          enddo

      enddo

    case default

      ! do nothing

  end select

and I am getting

Code:
SUB radon3d_temporal_fourier
Arguments
Local variables
stores a single trace
stores a single trace (extended to size of ft)
IMPLEMENTATION ---------------------------------------------------------------------------------
trace in the frequency domain
trace extended to size(ft)
  !!> SELECT TRANSFORMATION DIRECTION
    !!> time to frequency
              tr(nf) = 0.0  !!> ensures last sample is zero when nf > nt
    !!> frequency to time
              tcube(1:nt,ix,iy) = tr(1:nt)  !!> nt may be smaller than nt
do nothing

Almost correct. There is a problem that the match in sed

Code:
grep "!" radon3d_subs.f90 | sed 's/.*\! //'

removes the '!'

---------- Post updated at 06:44 AM ---------- Previous update was at 06:04 AM ----------

I tried the following

Code:
  !!
  !! SUB radon3d_temporal_fourier
  ! Arguments
  ! Local variables
  real, dimension(:), allocatable :: ft  ! stores a single trace
  real, dimension(:), allocatable :: tr  ! stores a single trace (extended to size of ft)
  ! trace in the frequency domain
  ! trace extended to size(ft)
  !!> SELECT TRANSFORMATION DIRECTION
    !!> time to frequency
              tr(nf) = 0.0  !!> ensures last sample is zero when nf > nt
    !!> frequency to time
              tcube(1:nt,ix,iy) = tr(1:nt)  !!> nt may be smaller than nt
      ! do nothing

Code:
grep "!" radon3d_subs.f90 | sed 's/(.*)(!.*)/\2/'

This produces the following. As you can see when I have '!!', these are changed to
a single '!'. How can I modify this so I get '!!'?

Code:
! SUB radon3d_temporal_fourier
! Arguments
! Local variables
! stores a single trace
! stores a single trace (extended to size of ft)
! trace in the frequency domain
! trace extended to size(ft)
!> SELECT TRANSFORMATION DIRECTION
!> time to frequency
!> ensures last sample is zero when nf > nt
!> frequency to time
!> nt may be smaller than nt
! do nothing

# 9  
Old 07-25-2012
Hi
csh so use this :
Code:
perl -ne 's/.*?\!/\!/; print if /\!/;' radon3d_subs.f90

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Fetching a line matching a pattern

Hi Gurus, I have a file as follows (Sample shown below but the list is very huge) SCHEDULE WS1#JS1 RUNCYCLE1 : WS1#JOB1 WS1#JOB2 FOLLOWS JOB1 END SCHEDULE WS2#JS1 RUNCYCLE2 : WS1#JOB3 WS1#JOB1 FOLLOWS JOB3 WS2#JOB1 (10 Replies)
Discussion started by: jayadanabalan
10 Replies

2. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

3. Shell Programming and Scripting

Matching pattern in two files and print the line

Hi, I want to match the pattern in file1 with file2 and print the value in file2 and paste in file1 file1: ISHO RT SR Major 96.46778 Drop Call Rate CS Critical 0.5072662 ISHO RT SR Major 97.754364... (3 Replies)
Discussion started by: khalil
3 Replies

4. Shell Programming and Scripting

Need correct pattern at end of line

I have some data as below. I need correct it as result. Data: BG1:100+10++II DG1:200+100+1234 DG2:300+200++II CG1:200+100+1111 DG2:400+100++II DG6:200+200+2345 DG2:400+100+2222 Result: BG1:100+10++II DG1:200+100+1234 DG2:300+200++1 CG1:200+100+1111 DG2:400+100++1... (4 Replies)
Discussion started by: mr.awk
4 Replies

5. UNIX Desktop Questions & Answers

matching 3 digits at the begining and the end of the line

I have a file with hundreds of records and I need to find those records that have three digits at the beginning and the same three digits at the end. $GREP '\(\)\(\)\(\)\3\2\1'I believe this is part of the script but I am not sure how to compare these 3 digits with the 3 digits at the end of... (2 Replies)
Discussion started by: bartsimpsong
2 Replies

6. Shell Programming and Scripting

Extracting a string matching a pattern from a line

Hi All, I am pretty new to pattern matching and extraction using shell scripting. Could anyone please help me in extracting the word matching a pattern from a line in bash. Input Sample (can vary between any of the 3 samples below): 1) Adaptec SCSI RAID 5445 2) Adaptec SCSI 5445S RAID 3)... (8 Replies)
Discussion started by: jharish
8 Replies

7. Shell Programming and Scripting

sed: Find start of pattern and extract text to end of line, including the pattern

This is my first post, please be nice. I have tried to google and read different tutorials. The task at hand is: Input file input.txt (example) abc123defhij-E-1234jslo 456ujs-W-abXjklp From this file the task is to grep the -E- and -W- strings that are unique and write a new file... (5 Replies)
Discussion started by: TestTomas
5 Replies

8. Shell Programming and Scripting

how to append the pattern at the end of the line

-Hi I have multiple files which contain a line with the word "exec". I need to add the following pattern " -cmode -ccheap" on the same line where "exec" is at the end. Any idea? Thanks a lot in advance to everybody... -A (2 Replies)
Discussion started by: aoussenko
2 Replies

9. Shell Programming and Scripting

comment/delete a particular pattern starting from second line of the matching pattern

Hi, I have file 1.txt with following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433 ** ** ** In file 2.txt I have the following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433... (4 Replies)
Discussion started by: imas
4 Replies

10. Shell Programming and Scripting

extract a particular start and end pattern from a line

hi In the foll example the whole text in a single line.... i want to extract text from IPTel to RTCPBase.h. want to use this acrooss the whole file Updated: IPTel\platform\core\include\RTCPBase.h \main\MWS2051_Sablime_Int\1... (7 Replies)
Discussion started by: manish205
7 Replies
Login or Register to Ask a Question