ksh

AWK in shell script - How to compare and merge TWO files based on a shared key (2 common fields)?

做~自己de王妃 提交于 2019-12-01 12:30:43
Could some one please help to compare two files, i have used the below command but i couldnt succeed on it, awk -F, 'NR == FNR {a[$1,$2]; next} (($1,$2) in a )' temp1.dat temp2.dat Here is my need, need to compare first two fields in the below two dat files and merge the result as expected in file3(first field, second field, 3 field of temp1.dat, 3 field of temp2.dat) File1:temp1.dat A, AB,100 B,BB,200 C,CC,300 File2:temp2.dat A,AB,10 C,CC,30 D,DF, 4 File3 :output A, AB,100,10 C,CC,300,30 awk -F, 'BEGIN{OFS=","}FNR==NR{a[$1$2]=$3;next}($1$2 in a && $3=$3","a[$1$2])' file2 file1 tested below: >

script doesn't run while executing in clearcase

别等时光非礼了梦想. 提交于 2019-12-01 10:52:31
I am trying to execute the following build script and it is returning no error but it is not executing the script inside it. there is a view tag with the following name. it can be seen with cleartool lsview <view-tag> . I can do cleartool setview <view-tag> but it doesn't run the sh /abc/cds/fg/bin/ant -t all. CLEARCASE_VIEWNAME=NYC_CYN cleartool setview -exec "newgrp orange; cd /abc/cds/fg/bin; sh /abc/cds/fg/bin/ant -t all -i ' '" $CLEARCASE_VIEWNAME Thanks for any help !! VonC First, don't use setview . It triggers a sub-shell, which doesn't play well with scripts. See " Python and

AWK in shell script - How to compare and merge TWO files based on a shared key (2 common fields)?

给你一囗甜甜゛ 提交于 2019-12-01 10:34:01
问题 Could some one please help to compare two files, i have used the below command but i couldnt succeed on it, awk -F, 'NR == FNR {a[$1,$2]; next} (($1,$2) in a )' temp1.dat temp2.dat Here is my need, need to compare first two fields in the below two dat files and merge the result as expected in file3(first field, second field, 3 field of temp1.dat, 3 field of temp2.dat) File1:temp1.dat A, AB,100 B,BB,200 C,CC,300 File2:temp2.dat A,AB,10 C,CC,30 D,DF, 4 File3 :output A, AB,100,10 C,CC,300,30 回答1

script doesn't run while executing in clearcase

一个人想着一个人 提交于 2019-12-01 08:45:13
问题 I am trying to execute the following build script and it is returning no error but it is not executing the script inside it. there is a view tag with the following name. it can be seen with cleartool lsview <view-tag> . I can do cleartool setview <view-tag> but it doesn't run the sh /abc/cds/fg/bin/ant -t all. CLEARCASE_VIEWNAME=NYC_CYN cleartool setview -exec "newgrp orange; cd /abc/cds/fg/bin; sh /abc/cds/fg/bin/ant -t all -i ' '" $CLEARCASE_VIEWNAME Thanks for any help !! 回答1: First, don't

ksh storing result of a command to a variable

戏子无情 提交于 2019-12-01 05:26:20
问题 I want to store the result of a command to a variable in my shell script. I cant seem to get it to work. I want the most recently dated file in the directory. PRODUCT= 'ls -t /some/dir/file* | head -1 | xargs -n1 basename' it wont work 回答1: you have two options, either $ or backsticks ` . 1) x=$(ls -t /some/dir/file* | head -1 | xargs -n1 basename) or 2) x=`ls -t /some/dir/file* | head -1 | xargs -n1 basename` echo $x Edit: removing unnecessary bracket for (2). 回答2: The problem that you're

How can I have term.el (ansi-term) track directories if using anyhting other than bash

孤街浪徒 提交于 2019-11-30 21:00:18
When using eshell or ansi-term and bash emacs changes the default-directory variable depending on what directory you are in. So if I move to /home/user/code/project and then use ido-find-file to open a file it starts ido with the CWD. If I use ksh (my normal shell) or zsh (tried for testing) it doesnt work. Is there a setting or is this just supported under bash? Thanks Put this in your .zshrc: chpwd() { print -P "\033AnSiTc %d" } print -P "\033AnSiTu %n" print -P "\033AnSiTc %d" The chpwd() function is run every time the pwd changes. The line ending in %d is the one that allows you to track

How do i replace [] brackets using SED

霸气de小男生 提交于 2019-11-30 17:40:22
I have a string that i am want to remove punctuation from. I started with sed 's/[[:punct:]]/ /g' But i had problems on HP-UX not liking that all the time, and some times i would get a 0 and anything after a $ in my string would dissappear. So i decided to try to do it manually. I have the following code which works on all my punctuation that I am interested in, except I cannot seem to add square brackets "[]" to my sed with anything else, otherwise it does not replace anything, and i dont get an error, so I am not sure what to fix. Anyways this is what i currently have and would like to add [

How to overcome an incompatibility between the ksh on Linux vs. that installed on AIX/Solaris/HPUX?

六眼飞鱼酱① 提交于 2019-11-30 14:42:22
I am involved in the process of porting a system containing several hundreds of ksh scripts from AIX, Solaris and HPUX to Linux. I have come across the following difference in the way ksh behaves on the two systems: #!/bin/ksh flag=false echo "a\nb" | while read x do flag=true done echo "flag = ${flag}" exit 0 On AIX, Solaris and HPUX the output is "flag = true" on Linux the output is "flag = false". My questions are: Is there an environment variable that I can set to get Linux's ksh to behave like the other Os's'? Failing that: Is there an option on Linux's ksh to get the required behavior?

Shell scripting input redirection oddities

十年热恋 提交于 2019-11-30 13:43:12
问题 Can anyone explain this behavior? Running: #!/bin/sh echo "hello world" | read var1 var2 echo $var1 echo $var2 results in nothing being ouput, while: #!/bin/sh echo "hello world" > test.file read var1 var2 < test.file echo $var1 echo $var2 produces the expected output: hello world Shouldn't the pipe do in one step what the redirection to test.file did in the second example? I tried the same code with both the dash and bash shells and got the same behavior from both of them. 回答1: A recent

Extract list of file names in a zip archive when `unzip -l`

浪尽此生 提交于 2019-11-30 12:28:02
问题 When I do unzip -l zipfilename , I see 1295627 08-22-11 07:10 A.pdf 473980 08-22-11 07:10 B.pdf ... I only want to see the filenames. I try this unzip -l zipFilename | cut -f4 -d" " but I don't think the delimiter is just " " . 回答1: Assuming none of the files have spaces in names: unzip -l filename.zip | awk '{print $NF}' My unzip output has both a header and footer, so the awk script becomes: unzip -l filename.zip | awk '/-----/ {p = ++p % 2; next} p {print $NF}' A version that handles