The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
make directory script malaysoul Shell Programming and Scripting 0 02-11-2007 11:10 AM
Help make script much easier GCTEII Shell Programming and Scripting 2 03-18-2006 10:12 AM
make my script wait Blip Shell Programming and Scripting 4 01-23-2004 12:30 PM
make and make install commands gerwhelan UNIX for Dummies Questions & Answers 4 07-03-2003 06:49 AM
make script cherio High Level Programming 3 11-11-2002 10:06 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-16-2008
sickboy sickboy is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 62
How to make a script out of commands

Hi,

I have a very basic knowledge of Unix and I need your help for a small script that will do the following commands that I do manually by just giving the filename TPR20080414.txt

Code:
cut -d'|' -f3,4 TPR20080414.txt> oe_012.lkp
awk -F "|" '{temp=$1;$1=$2;$2=temp}1' OFS="|" oe_012.lkp > oe_013.lkp
unix2dos oe_012.lkp
unix2dos oe_013.lkp
Thanks in advance
  #2 (permalink)  
Old 06-16-2008
ynir ynir is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 35
Code:
#!/bin/bash

if [ $# -ne 1 ]; then
        echo "Use as: $0 filename" >&2
        exit 1
fi
cut -d'|' -f3,4 ${1} > oe_012.lkp
awk -F "|" '{temp=$1;$1=$2;$2=temp}1' OFS="|" oe_012.lkp > oe_013.lkp
unix2dos oe_012.lkp 2>/dev/null
unix2dos oe_013.lkp 2>/dev/null
  #3 (permalink)  
Old 06-16-2008
ynir ynir is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 35
btw, you can replace the awk line with:
Code:
awk -F "|" '{print $2, $1}' OFS="|" oe_012.lkp > oe_013.lkp
  #4 (permalink)  
Old 06-16-2008
sickboy sickboy is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 62
Works great!
How I can add as first lines

AAADATE20080528|IZA in the oe_012.lkp

and IZA|AAADATE20080528 in the oe_13.lkp

where 20080528 is the system date in this form?
Is it possible to put this script in a central place in a server and then everybody can run by just typing script.sh??? What changed should I make?
Closed Thread

Bookmarks

Tags
unix commands

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:38 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0