How can we do this!?

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers How can we do this!?
# 15  
Old 06-05-2017
Linux and csh.

---------- Post updated at 02:17 AM ---------- Previous update was at 02:14 AM ----------

Second command is not the one I am giving. It is the getting displayed once I run your's command. I don't know how
Code:
!$

is every time replaced by
Code:
test

.
# 16  
Old 06-05-2017
Looks like !$ has a special meaning in csh, even if showing up within single quotes. As I don't have any knowledge on csh, I'll have to stop my attempts to help.
# 17  
Old 06-05-2017
Many many thanks. RudiC and Ravinder, I tried your command with changing the shell to bash and it worked.
# 18  
Old 06-05-2017
... gnash ...

Shamelessly stealing RavinderSingh13's idea, I managed to compose this:
Code:
awk '
NR == 1 {for (n = split (CHK, T); n>0; n--) C[T[n]] 
        }
        {for (c in C) if (!$c) $c = OLD[c]
         split ($0, OLD)
        }
1
' FS="," OFS="," CHK="2,4" file

# 19  
Old 06-06-2017
Would this work?
Code:
perl -nlaF, -e '$,=","; for(0..$#F){$p[$_]=$F[$_]if$F[$_]} print @p' indra2011.example
101,103,1,2,3
101,103,1,2,3
101,103,1,4,5
201,234,7,8,9
201,234,7,4,5

# 20  
Old 06-06-2017
Quote:
Originally Posted by RudiC
Looks like !$ has a special meaning in csh, even if showing up within single quotes.
As it is, it does, because it is part of cshs commandline-editing.

I hope this helps.

bakunin

/PS: I forgot to add: the exclamation mark needs to be escaped in csh even in strong quoting (single quotes).

Last edited by bakunin; 06-06-2017 at 03:57 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question