How to make a script out of commands


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to make a script out of commands
# 1  
Old 06-16-2008
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  
Old 06-16-2008
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  
Old 06-16-2008
btw, you can replace the awk line with:
Code:
awk -F "|" '{print $2, $1}' OFS="|" oe_012.lkp > oe_013.lkp

# 4  
Old 06-16-2008
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?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

I have two commands “ls -h” and “ls -ltr”. How do i make sure “ls -ltr” is run after “ls -h” is suc

help me (2 Replies)
Discussion started by: sonu pandey
2 Replies

2. Programming

Using basic UNIX commands to make/compile JAVA files

Hello! This is my first post, and I just learned what UNIX was this week. For a JAVA programming class I am taking, I must be able to create a directory in UNIX, use the nano command to create a JAVA program, compile it, and then run it on the command prompt using the java command. For some... (5 Replies)
Discussion started by: UNdvoItX
5 Replies

3. UNIX for Dummies Questions & Answers

Make directory in script

I'm creating a file that reads: cd $HOME echo What would you like to call the tar file? read TARNAME tar -cf $TARNAME.tar labs/* mkdir backups mv $TARNAME.tar backups/ Now my problem I'm having is that some people have the backups directory and some don't. How can I make it that if they... (1 Reply)
Discussion started by: bbowers
1 Replies

4. UNIX for Dummies Questions & Answers

how to make script automated

if i have a script called test.sh file1=$(ls -l|awk '{print $9 $1}') awk ' /date_of_selling:/ { print $6 ":" &9 }' /$file1 >> data.txt if i wanna this script to run automatically every day at 8 am :D (3 Replies)
Discussion started by: teefa
3 Replies

5. UNIX for Dummies Questions & Answers

How to make delays between multiple commands in an alias (ircII)?

Okay so I have an alias that looks like this: ALIAS gscn { MSG gscn Test1 MSG gscn Test2 MSG gscn Test3 MSG gscn Test4 MSG gscn Test5 } How do I make it wait 5 seconds between each command before it executes the next one after that in order from top to bottom? I tried the TIMER... (1 Reply)
Discussion started by: guitarscn
1 Replies

6. Shell Programming and Scripting

how to run script? call other script? su to another user? make a cron?

Good morning. I am searching for "how-to"'s for some particular questions: 1. How to write a script in HP-UX 11. 2. How to schedule a script. 3. How to "call" scripts from the original script. 4. How to su to another user from within a script. This is the basics of what the... (15 Replies)
Discussion started by: instant000
15 Replies

7. Shell Programming and Scripting

Make ssh and send commands

Hi, I'm trying to make an SSH into a SGSN node and collect some commands printouts.:confused: I really don't know how this can be done. I think it must be like this: #!/bin/bash ssh user@192.168.88.10 Then I must enter the password, but I don't know how to do it, I tried with: echo... (3 Replies)
Discussion started by: nagomes
3 Replies

8. UNIX for Dummies Questions & Answers

Cannot use Make commands

I just cant use any of the make commands. Any ideas? I already tried adding the path of the make command in my profile But nothing happened The error returned is Make: Could not read current directory. Stop. Please help me on this. (1 Reply)
Discussion started by: khestoi
1 Replies

9. UNIX for Dummies Questions & Answers

make and make install commands

Hi there, I am installing a package at the moment on to my Solaris version 8 and I have run into a problem with the 'make' command. I have installed the package using the 'pkgadd' command and I am now at the stage where I have to use the 'make' command followed by the 'make install'... (4 Replies)
Discussion started by: gerwhelan
4 Replies

10. Programming

make script

I need to write a make script to install a C module in a UNIX environment.It should install the sources, build the libraries and install them and also install the info pages on the system. Can this script be general enough to also install on windows, windows dll, windows help file's etc. Any... (3 Replies)
Discussion started by: cherio
3 Replies
Login or Register to Ask a Question