sed and cut command in variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed and cut command in variable
# 1  
Old 09-30-2013
sed and cut command in variable

hi,
i want to remove 12 and 13 column from psv files and dump them in new folder

Code:
ls -ltr *GTDA_Dly_Pmix_*.psv>filename.xls

var1=`cat filename.xls`

for i in $var1
 do
var3=`echo "$i" |cut -d '|' -f12,13 |sort -u`
sed -e 's/"|$var3"//g "$i">/dm/RMDW_LandingZone/archive/Analysis/renu/abac/temp2
done


Smilie

thanks in advance

Last edited by Franklin52; 09-30-2013 at 10:34 AM.. Reason: Please use code tags
# 2  
Old 09-30-2013
Something like this ?

Code:
awk -F'|' '{$12=$13=z}1' OFS='|' *.psv | sed 's/||*/|/g' >/dm/RMDW_LandingZone/archive/Analysis/renu/abac/temp2

Code:
$ cat f1
1|2|3|4|5|1|2|3|4|5|1|2|3|4|5|6
1|2|3|4|5|1|2|3|4|5|x|y|T|j|5|6
$ cat f2
1|2|3|4|5|1|2|3|4|5|1|2|3|4|5|6
1|2|3|4|5|1|2|3|4|5|R|T|8|G|5|6
$ awk -F'|' '{$12=$13=z}1' OFS='|' f* | sed 's/||*/|/g'
1|2|3|4|5|1|2|3|4|5|1|4|5|6
1|2|3|4|5|1|2|3|4|5|x|j|5|6
1|2|3|4|5|1|2|3|4|5|1|4|5|6
1|2|3|4|5|1|2|3|4|5|R|G|5|6
$

This User Gave Thanks to ctsgnb For This Post:
# 3  
Old 10-04-2013
fast load

i want to export data from teradata to linux file through fastload scriPT.
but my teradata table has column which cotains timestamp so i want to export only two day old (current_date -2) data using that columns.

teradata table :timestamp column has below datatype
FILE_DW_ARRV_TS TIMESTAMP(6),

FILE_DW_ARRV_TS
2013-08-20 09:58:00.000000
2013-05-31 05:09:00.000000

thanks in advance!!!Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Use cut output as variable piped awk command

Hi, I would like use the output of my cut command as a variable in my following awk command. Here's what I've written. cut -f1 info.txt | awk -v i=xargs -F'' '{if($6 == $i) print $20}' summary.txt Where obviously the 'xargs' doesn't do what I want. How can I pass my cut result to my awk... (3 Replies)
Discussion started by: heyooo
3 Replies

2. Shell Programming and Scripting

Storing command output in a variable and using cut/awk

Hi, My aim is to get the md5 hash of a file and store it in a variable. var1="md5sum file1" $var1 The above outputs fine but also contains the filename, so somthing like this 243ASsf25 file1 i just need to get the first part and put it into a variable. var1="md5sum file1"... (5 Replies)
Discussion started by: JustALol
5 Replies

3. UNIX for Advanced & Expert Users

Place the results of a CUT command into a variable

I am being passed a file in UNIX, ie: variable.txt I need to extract the first part of the file content, up to the period, content ie: common_dir.second_output cut -d'.' -f1 /content/stores/variable.txt I then need to utilize the results to create a variable ($1), and test on that... (4 Replies)
Discussion started by: talonbow
4 Replies

4. Shell Programming and Scripting

sed command with variable

Hi, I want to insert some text in the begning of each line. But issue is the text that i want to insert is stored into one variable. so my command look like constr="`date | awk '{print $3"-"$2"-"$6}'`",MXGBTST1" " sed 's/^/\$constr/g' alert_temp.csv but sed command instead of taking... (3 Replies)
Discussion started by: ranvijaidba
3 Replies

5. Homework & Coursework Questions

sed & cut command issues

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: After using the egrep command to pull certain lines from the asg5f1 (creating the asg5f1c file), I am required... (1 Reply)
Discussion started by: robrom78
1 Replies

6. Shell Programming and Scripting

Line/Variable Editing for Awk sed Cut

Hello, i have a file, i open the file and read the line, i want to get the first item in the csv file and also teh third+6 item and wirte it to a new csv file. only problem is that using echo it takes TOO LONG: please help a newbie. below is my code: WorkingDir=$1 FileName=`cut -d ',' -f... (2 Replies)
Discussion started by: limamichelle
2 Replies

7. UNIX for Dummies Questions & Answers

sed insert command and variable expansion/command substitution

I know this script is crummy, but I was just messing around.. how do I get sed's insert command to allow variable expansion to show the filename? #!/bin/bash filename=`echo $0` /usr/bin/sed '/#include/ { i\ the filename is `$filename` }' $1 exit 0 (8 Replies)
Discussion started by: glev2005
8 Replies

8. UNIX for Dummies Questions & Answers

Cut Command value assign to variable

Hi, I am new to UNIX Scripting. I have been trying to use the CUT command to retrieve part of the header from a file and assign it to a variable. I have tried searching a lot, but I am still unsuccessful. Sample Header: HJAN BALANCE 20090616 I need to retrieve the date here, which always... (10 Replies)
Discussion started by: ragz_82
10 Replies

9. Shell Programming and Scripting

Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong: sed "2i\\${n}Category:$cat\n" Sample: Titel Blahh Blahh abllk sdhsd sjdhf Blahh Blah Blahh Blahh Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies

10. Shell Programming and Scripting

Passing a variable to sed or cut

:confused: Is it possible to send a variable to a sed or cut command? I have a test script as below: counter=1 while read line do # Test the file printf "$line" > temp$counter pref=$(cut c1-2000 $temp$counter | sed 's///g' | sed 's|.*PutTime\(.*)Origin.*|\1|') printf" let... (5 Replies)
Discussion started by: gugs
5 Replies
Login or Register to Ask a Question