Monday, May 13, 2013

Order Management Tables - 11i


Order Management Tables.
Entered
oe_order_headers_all
1 record created in header table
oe_order_lines_all Lines for particular records
oe_price_adjustments
When discount gets applied
oe_order_price_attribs
If line has price attributes then populated
oe_order_holds_all
If any hold applied for order like credit check etc.

Booked
oe_order_headers_all
Booked_flag=Y Order booked.
wsh_delivery_details Released_status Ready to release

Pick Released
wsh_delivery_details Released_status=Y Released to Warehouse (Line has been released to Inventory for processing)
wsh_picking_batches
After batch is created for pick release.
mtl_reservations This is only soft reservations. No physical movement of stock

Full Transaction
mtl_material_transactions
No records in mtl_material_transactions
mtl_txn_request_headers
mtl_txn_request_lines

wsh_delivery_details Released to warehouse.
wsh_new_deliveries if Auto-Create is Yes then data populated.
wsh_delivery_assignments deliveries get assigned
Pick Confirmed
wsh_delivery_details
Released_status=Y Hard Reservations. Picked the stock. Physical movement of stock

Ship Confirmed
wsh_delivery_details Released_status=C Y To C:Shipped ;Delivery Note get printed Delivery assigned to trip stopquantity will be decreased from staged
mtl_material_transactions On the ship confirm form, check Ship all box
wsh_new_deliveries If Defer Interface is checked I.e its deferred then OM & inventory not updated. If Defer Interface is not checked.: Shipped
oe_order_lines_all Shipped_quantity get populated.
wsh_delivery_legs 1 leg is called as 1 trip.1 Pickup & drop up stop for each trip.
oe_order_headers_all
If all the lines get shipped then only flag N
Autoinvoice
wsh_delivery_details Released_status=I Need to run workflow background process.
ra_interface_lines_all
Data will be populated after wkfw process.
ra_customer_trx_all
After running Autoinvoice Master Program for
ra_customer_trx_lines_all specific batch transaction tables get populated

Price Details
qp_list_headers_b To Get Item Price Details.
qp_list_lines


Items On Hand Qty
mtl_onhand_quantities TO check On Hand Qty Items.

Payment Terms
ra_terms Payment terms

AutoMatic Numbering System
ar_system_parametes_all you can chk Automactic Numbering is enabled/disabled.

Customer Information
hz_parties Get Customer information include name,contacts,Address and Phone
hz_party_sites
hz_locations
hz_cust_accounts
hz_cust_account_sites_all
hz_cust_site_uses_all
ra_customers

Document Sequence
fnd_document_sequences Document Sequence Numbers
fnd_doc_sequence_categories
fnd_doc_sequence_assignments

Default rules for Price List
oe_def_attr_def_rules Price List Default Rules
oe_def_attr_condns
ak_object_attributes

End User Details
csi_t_party_details To capture End user Details
Sales Credit Sales Credit Information(How much credit can get)
oe_sales_credits

Attaching Documents
fnd_attached_documents Attched Documents and Text information
fnd_documents_tl
fnd_documents_short_text

Blanket Sales Order
oe_blanket_headers_all
Blanket Sales Order Information.
oe_blanket_lines_all

Processing Constraints
oe_pc_assignments
Sales order Shipment schedule Processing Constratins
oe_pc_exclusions

Sales Order Holds
oe_hold_definitions
Order Hold and Managing Details.
oe_hold_authorizations
oe_hold_sources_all
oe_order_holds_all

Hold Relaese
oe_hold_releases_all
Hold released Sales Order.

Credit Chk Details
oe_credit_check_rules
To get the Credit Check Againt Customer.

Cancel Orders
oe_order_lines_all Cancel Order Details.

crontab - Schedule the process in Unix


  • Cron job are used to schedule commands to be executed periodically. 
  • can setup set up commands or scripts, which will repeatedly run at a set time. 
  • The cron service (daemon) runs in the background and constantly checks the /etc/crontab file, 
  • To edit your crontab file, type the following command at the UNIX / Linux shell prompt:  $ crontab -e
Example :
     1 2 3 4 5 /root/email_notifications.sh  argument1 argument2
Where
  • 1 Minutes (0-59)
  • 2 Hours (0-23)
  • 3 Day of Month (1-31)
  • 4 Month (1-12)
  • 5 Day of Week (0-7) Sunday=0
Run the invoice program in working hours only

00 09-18 * * 1-5 invoice_sh "Customer_Number"

Run the program concurrent_fail_list_sh in every 10 mins

*/10 * * * * concurrent_fail_list_sh

Run the program customer_info_sh for every mins

* * * * *  customer_info_sh

Special Key words
Keyword Equivalent
@yearly 0 0 1 1 *
@daily 0 0 * * *
@hourly 0 * * * *
@reboot Run at startup.

Run the program customer_info_sh yearly once

@yearly  customer_info_sh

Run the program customer_info_sh daily once

@daily  customer_info_sh

Run the program customer_info_sh hourly once

@hourly  customer_info_sh

Run the program customer_info_sh after system boot up

@reboot  customer_info_sh

List the scheduled jobs for particular user

$crontab -u username -l

Add the new job in crontab use the below commands

$crontab -e





tr - Translate command in Unix



  • The tr utility copies the given input to produced the output with substitution or deletion of selected characters. 
  • It takes as parameters two sets of characters, and replaces occurrences of the characters in the first set with the corresponding elements from the other set 

Syntax : 

tr [options] "set1" "set2"
tr "set1" "set2" < input.txt
tr "set1" "set2" < input.txt > output.txt

Translate the word 'linux' to upper-case:


$ echo "linux"|tr "a-z" "A-Z"
LINUX

Remove all two more successive blank spaces from a copy of the text in a file called input.txt

tr -s ' ' ' ' < input.txt


To replace every sequence of one or more new lines with a single new line: 
tr -s '\n' < input.txt 

To replace every sequence of one or more new lines with a single new line and remove the consecutive spaces in the word.

tr -s '\n' < input.txt |tr -s ' ' ' '




Delete the special characters in a file


To remove the carriage return from the carriage return/newline pair used by Microsoft OSes as a line terminator 
tr -d '\r' < pc.file > unix.file 

To delete all NULL characters from a file:
tr -d '\0' < textfile > newfile 

To replace every sequence of characters in the <space> character class with a single : (colon) character, enter: 
tr -s '[:space:]' '[\:*]' < in_file 




find - Files/Directories search Command in Unix

find is used to search files or directories in particular directories and its sub-directories. Which is very powerful search command in unix.

Syntax : find [start search locations] -name "<file name or dierctory name>" 

Examples :
$find / -name ‘searchFileName’ -type f

find the file name ‘searchFileName’ start from the root directory and subdirectory

 $find . –name ‘searchFileName’ -type f
Find the file name ‘searchFileName’ start from the current directory  (where  this command should executed) and its sub directory

$ find . -name "*.htm*" -type f
find the files end with .htm from current directory.

$ find . -name "*" -type f -size  +1000
    This is used to find all files with size greater than 1000k from current directory.

$ find . -name foo.bar -type f  2> /dev/null
    This is used to find foo.bar file ,suppose it does not have any access permission it eliminate error message( 2>/dev/null).

$ find . -type d
This is used to find all directory only.

$ find . -type f
This is used to find all normal files from current directory.

Finding files according to date and time

$find /home -atime +7 -type f

-atime +7: All files that were last accessed more than 7 days ago
-atime 7: All files that were last accessed exactly 7 days ago
-atime -7: All files that were last accessed less than7 days ago

$find /home -mtime +7 -type f

-mtime +7: All files that were last modified more than 7 days ago
-mtime 7: All files that were last modified exactly 7 days ago
-mtime -7: All files that were last modified less than7 days ago

The power of find with grep

$find . –name ‘*.txt’ –exec rm {} \;

This is used to find all .txt files and deleted all.

$find . -name '123' -exec grep 'python' {} \;

This is used to find ‘python’ word in a file name 123 and it shows line which occur in a file.

$find . -name '123' -exec grep -l 'python' {} \;

This is used to find ‘python’ word in a file name 123 and it shows the path of the file.

$find . -maxdepth 1 -name "*" -type f -exec egrep -i '(search_string1|search_string2)' {}\;

This is used to find the file name and its content which is occured the search string1 and search string2 from the current directory. it wont proceed the search process to subdirectories. Can control search directories using maxdepth.

$find . -maxdepth 1 -name "*" -type f -exec egrep -il '(search_string1|search_string2)' {}\;

This is used to find the file names only which is occured the search string1 and search string2 from the current directory. it wont proceed the search process to subdirectories.

find . -maxdepth 1 -name "*" ! \( -name "*.dat*" -o -name "*.log*" -o -name "*.csv*" \) -type f


This is used to find all the files except the file end with .dat, .log and .csv



UTL_FILE in Usage


Uses of UTL_FILE package:
  • In Oracle PL/SQL, UTL_FILE is an Oracle supplied package which is used for file operations (read and write) in conjunction with the underlying operating system.
  • UTL_FILE works for both server and client machine systems. A directory has to be created on the server, which points to the target file.
  • For the files located on the server machine, the actual path can be given while creating the directory.
  • For the files which are located on the client machines, however, the relative path is required along with the client machine name.
  • In addition, the relative file path must be in shared mode with read and write access for the required users.
  • A DBA must create the directory and then grant Read/Write access to the required users.
How to create file in executing pl/sql procedure by using UTL_FILE package:
Pre-requisites to perform the aove mentioned functionality

1. Directory should present in the database
2. Directory should have the read/write permissions 
3. Inorder to get the directory name we will use table named dba_directories

Code to create CSV file which is taking the values from table in database by using UTL_FILE

DECLARE
   CURSOR stud_cur
   IS
      SELECT *  FROM student;
      v1_file   UTL_FILE.file_type;
      lv_directory VARCHAR2(30) := 'VENDFILES'; -- Directory Name
      lv_file      VARCHAR2(30) := 'test_JACK.csv';  -- File Name
BEGIN
   v1_file := UTL_FILE.fopen (lv_directory, lv_file, 'w');

   FOR stud_rec IN stud_cur
   LOOP
      UTL_FILE.put_line (v1_file, '"' || stud_rec.student_id || '","' || stud_rec.student_name ||'","' || stud_rec.address ||'","' || stud_rec.marks || '"');
   END LOOP;

   UTL_FILE.fclose (v1_file);
EXCEPTION
   WHEN UTL_FILE.invalid_path
   THEN
      fnd_file.put_line (fnd_file.LOG, 'INVALID PATH' || SQLERRM);
   WHEN UTL_FILE.invalid_mode
   THEN
      fnd_file.put_line (fnd_file.LOG, 'THE OPEN_MODE PARAMETER IN FOPEN WAS INVALID' || SQLERRM);
   WHEN UTL_FILE.invalid_filehandle
   THEN
      fnd_file.put_line (fnd_file.LOG, ' THE FILE HANDLE WAS INVALID' || SQLERRM);
   WHEN UTL_FILE.invalid_operation
   THEN
      fnd_file.put_line (fnd_file.LOG,'THE FILE COULD NOT BE OPENED OR OPERATED ON AS REQUESTED' || SQLERRM );
   WHEN UTL_FILE.write_error
   THEN
      fnd_file.put_line (fnd_file.LOG,'AN OPERATING SYSTEM ERROR OCCURRED DURING THE WRITE OPERATION' || SQLERRM);
   WHEN UTL_FILE.internal_error
   THEN
      fnd_file.put_line (fnd_file.LOG, 'AN UNSPECIFIED ERROR IN PL/SQL' || SQLERRM);
   WHEN NO_DATA_FOUND
   THEN
      fnd_file.put_line (fnd_file.LOG, 'NO DATA FOUND' || SQLERRM);
   WHEN OTHERS
   THEN
      fnd_file.put_line (fnd_file.LOG, 'OTHERS ERROR' || SQLERRM);
END;


Read the file content using UTL_FILE

set serveroutput on;
DECLARE
 vInHandle utl_file.file_type;
 vNewLine  VARCHAR2(250);
 lv_directory VARCHAR2(30) := 'VENDFILES'; -- Directory
 lv_file      VARCHAR2(30) := 'student.dat'; -- Data file
BEGIN
  vInHandle := utl_file.fopen(lv_directory, lv_file, 'R');
  LOOP
    BEGIN
      utl_file.get_line(vInHandle, vNewLine);
      dbms_output.put_line(vNewLine);
    EXCEPTION
      WHEN OTHERS THEN
        EXIT;
    END;
  END LOOP;
  utl_file.fclose(vInHandle);
END;



Sunday, May 12, 2013

Create SQL*Loader Concurrent Program in R12

SQL*Loader Usage:
                                   SQL LOADER is an Oracle utility used to load data into table given a data file which has the records that need to be loaded. SQL*Loader takes  data file, as well as a control file, to insert data into the table. When a Control file is executed, it can create Three (3) files called log file, bad file or reject file, discard file.


Log file tells you the state of the tables and indexes and the number of logical records already read from the input data file. This information can be used to resume the load where it left off.

 Bad file or reject file gives you the records that were rejected because of formatting errors or because they caused Oracle errors.

Discard file specifies the records that do not meet any of the loading criteria like when any of the WHEN clauses specified in the control file. These records differ from rejected records.

Structure of the data file:
1.Data file can be in fixed record format
2.Variable record format.

 Fixed Record Format would look like the below. In this case you give a specific position where the Control file can expect a data field:

INV100AMOUNT3000ADDRCHENNAI
INV102AMOUNT5000ADDRCHENNAI

Control file example :



LOAD DATA
INFILE '$FILE_NAME'
APPEND
INTO TABLE student
FIELDS TERMINATED BY '|'
TRAILING NULLCOLS
( STUDENT_ID                POSITION(1:6)   INTEGER,
  STUDENT_NAME        POSITION(7:15)  CHAR,
  ADDRESS                      POSITION(15:20) CHAR,
  MARKS                          POSITION(20:40) INTEGER
 )


Variable record format : Data file having the delimiter based values.

Create Table : student


CREATE TABLE student(student_id   NUMBER,
                     student_name VARCHAR2(50),
                     address      VARCHAR2(100),
                     marks        NUMBER
                     )


Below is the step by step process of registering shell script as a host program or concurrent program in Oracle Applications R12

Step 1 : Create the Executable name SQLLDR_TEST_PROGRAM with Executable file Name as sqlldr_demo_prog



Step 2 : Register the concurrent program Demo SQL*Loader Concurrent Program



Step 3 : Adding the parameter in the concurrent program




Step 4:  Add the concurrent program in to the request group & Add that request group into the Responsibility.

Create the control file sqlldr_demo_prog.ctl under $CUSTOM_TOP/bin directory

LOAD DATA
INFILE '$FILE_NAME'
APPEND
INTO TABLE student
FIELDS TERMINATED BY '|'
TRAILING NULLCOLS
( STUDENT_ID                    DECIMAL EXTERNAL,
  STUDENT_NAME            CHAR,
  ADDRESS                          CHAR,
  MARKS                              DECIMAL EXTERNAL
 )


$FILE_NAME --> We can hard code the file name with full directory path else we can pass the file name with file location as parameter. 

Note : We can put it OPTIONS (SKIP = 1)   --The first row in the data file is skipped without loading

Place the data file sqlldr_data_file.dat under under /u06/app/applmgr/dvoa044/oc/1.0.0/bin directory

1000|Chidambaram|Chennai|98
1001|Ram|Bangalore|67
1002|Kamal|Chennai|89
1003|Preethi|Hyderabad|90

Note : can use any directory for data file path.


Step 5: Submit the concurrent program Demo SQL*Loader Concurrent Program
from Added responsibility

Program should be completed in normal and out put parameter values are displayed in log file.



Log Information :

Control File:   /u06/app/applmgr/dvoa044/oc/1.0.0/bin/sqlldr_demo_prog.ctl
Data File:      /u06/app/applmgr/dvoa044/oc/1.0.0/bin/sqlldr_data_file.dat
  Bad File:     /u06/app/applmgr/dvoa044/out/o55553058.out
  Discard File: /u06/app/applmgr/dvoa044/out/o55553058.out 
 (Allow all discards)

Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array:     64 rows, maximum of 65536 bytes
Continuation:    none specified
Path used:      Conventional

Table STUDENT, loaded from every logical record.
Insert option in effect for this table: APPEND
TRAILING NULLCOLS option in effect

   Column Name                  Position   Len  Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
STUDENT_ID                          FIRST     *   |       CHARACTER            
STUDENT_NAME                  NEXT     *   |       CHARACTER            
ADDRESS                                NEXT     *   |       CHARACTER            
MARKS                                   NEXT     *   |       CHARACTER            


Table STUDENT:
  4 Rows successfully loaded.
  0 Rows not loaded due to data errors.
  0 Rows not loaded because all WHEN clauses were failed.
  0 Rows not loaded because all fields were null.


Space allocated for bind array:                  65016 bytes(63 rows)
Space allocated for memory besides bind array:        0 bytes

Total logical records skipped:         0
Total logical records read:              4
Total logical records rejected:        0
Total logical records discarded:      0

Run began on Mon May 13 01:51:57 2013
Run ended on Mon May 13 01:51:58 2013

Elapsed time was:     00:00:00.81
CPU time was:         00:00:00.02    

Data's are successfully inserted into back-end table student



sqlldr used in unix code

The below code can be used in unix shell script.


sqlldr ${FCP_LOGIN} control=$CUSTOM_PATH/bin/sqlldr_demo_prog.ctl log=sqlldr_data_file.log bad=sqlldr_data_file.bad  data=sqlldr_data_file.dat 

${FCP_LOGIN}  --> This is default credentials for APPS ,It provides Oracle Database User Name/Password@DataBase name, 

we can hardcode those values like USERID=apps/apps_passwd@apps_database

If the data file having invalid content then only bad file will be created otherwise bad file wont created.

REGEX for n characters or at least m characters in Unix

{m} Match the prceeding characters exactly m times



Examples Correct Incorrect
A{3} AAA A


AA


AAAA


AAAAA
{m,} Match the prceeding characters atleast m times



Examples Correct Incorrect
A{3,} AAA A

AAAA AA

AAAAA






{min,max} Match the prceeding characters between min and max times



Examples Correct Incorrect
A{3,5} AAA A

AAAA AA

AAAAA AAAAAA


AAAAAAA




Examples :

File Name : numbers.dat

12
12345
123456
12345678
10.1
.1



grep '^[0-9]\{6\} numbers.dat # line should be start between number 0 to 9 and length of the digit is exactly 6

grep '^[0-9]\{4,6\} numbers.dat# line should be start between number 0 to 9 and length of the digit is between 4 and 6

grep '^[0-9]\{3,\} numbers.dat # line should be start between number 0 to 9 and length of the digit is minimum 3

grep '^\.[0-9]' numbers.dat # line should be start with .(dot) and followed by digits


grep (Global Regular Expression Parser) Command in Unix

  • Search file(s) for specific text. 
  • By default, grep displays the matching lines. 
  • Search pattern allows regular expression
Syntax : $grep [options] [find pattern] [filename]

Options Descriptions
-v Print all lines that dont match pattern
-n Print the matched line and its line number
-l Print only the names of files with matching lines
-c Print only the count of matching lines
-i Match either upper or lowercase
-w Print the lines which is matched exact given word
-r Recursive search folder and sub-folder
Example:

file name : sample.dat

applas11i13
sunday is holiday
monday
tuesday
wednesday
thursday
friday
saturday
Sunday SUCCESS
SUNDAY 1234
SUUNDAY
this


$ grep "Sunday" sample.dat
Sunday SUCCESS

This is used to find the line in which the word ‘Sunday’ in a file ‘sample.dat’ occurs  . This is also case sensitive.

$ grep -i "Sunday" sample.dat
sunday is holiday
Sunday SUCCESS
SUNDAY 1234

This is used to find the line in which the word ‘Sunday’ in a file ’sample.dat’ occurs. This is ignoring the case sensitive.

$ grep -v "Sunday" sample.dat
applas11i13
sunday is holiday
monday
tuesday
wednesday
thursday
friday
saturday
SUNDAY 1234
SUUNDAY
this

This is used to find all the line except the word ‘Sunday’  in a file ‘sample.dat’. This is also case sensitive.

$ grep -iv "Sunday" sample.dat
applas11i13
monday
tuesday
wednesday
thursday
friday
saturday
SUUNDAY
this

  This is used to find all the line except the word ‘Sunday’ in a file ‘sample.dat’. This is ignoring case sensitive.

$ grep -w "is" sample.dat
sunday is holiday

           This is used to find the line in which the word ‘is’ occurs  in a file ‘sample.dat’. This is also case sensitive.

$ grep  "is" sample.dat
sunday is holiday
this 

       This is used to find the line in which  the  word ‘is’ occurs in a file ‘sample.dat’. This is also case sensitive.



Saturday, May 11, 2013

Regular Expression Pattern matching (grep,egrep)

?              any single char.
[abcd]      any single char from the specified list 
[!abcd]     any single char other than one from the specified list.
[a-z]         any char between “a” and “z” inclusive 
[!a-z]        any char other than between “a” and “z” inclusive 


?
      The question mark indicates there is zero or one of the preceding element. example, colou?r matches both "color" and "colour".

* 
      The asterisk indicates there is zero or more of the preceding element.

example, ab*c matches "ac", "abc", "abbc", "abbbc", and so on.

The plus sign indicates there is one or more of the preceding element. example, ab+c matches "abc", "abbc", "abbbc", and so on, but not "ac".

GREP with Regular Expression

REGULAR EXPRESSIONS

.
  Matches single character
*   Any character comes 0 or more times
[] any character contains within bracket
^ starting character
$ End of the character

Examples:

file name : sample.dat

applas11i13
sunday is holiday
monday
tuesday
wednesday
thursday
friday
saturday
Sunday SUCCESS
SUNDAY 1234
SUUNDAY
this

The file content sample.dat ends with s lines only displayed

$ grep s$ sample.dat
this

The file content sample.dat must start with t lines only displayed

$ grep ^t sample.dat
tuesday
thursday
this

. (dot) place any character will come with in the file sample.dat content

$ grep fri.ay sample.dat
friday

The file content sample.dat must start with a-f  lines only displayed

$ grep ^[a-f] sample.dat
applas11i13
friday

f may come 0 or more times but that line must occurs y

$ grep f*y sample.dat
sunday is holiday
monday
tuesday
wednesday
thursday
friday
saturday
Sunday SUCCESS

The word must start with f and ends with y in between any no of characters  are allowed.

$ grep f.*y sample.dat
friday

EGREP (Extended Global Regular Expression Parser)


 grep command is used to search the contents of files that matches a particular criteria.
 grep - basic regular expressions
 egrep - uses extended regular expressions

It prints sunday or monday line in file sample.dat

$ egrep '(sun|mon)day' sample.dat
sunday is holiday
monday

It display all line which have end with day in file sample.dat
? means previous word  comes 0 or 1 times

$ egrep '(sun|mon)?day' sample.dat
sunday is holiday
monday
tuesday
wednesday
thursday
friday
saturday
Sunday SUCCESS

It shows line starts with any one of character [s or m or t] mandatory and followed by any character or word will come but it must ends with day in file sample.dat

$ egrep '^(s|m|t)+.*day$' sample.dat
sunday is holiday
monday
tuesday
thursday
saturday

It shows line starts with s or ends with s in file sample.dat

$ egrep '^(s)|s$' sample.dat
sunday is holiday
saturday
this

It shows line starts with any character except s in file sample.dat

$ egrep '^[^s]' sample.dat
applas11i13
monday
tuesday
wednesday
thursday
friday
Sunday SUCCESS
SUNDAY 1234
SUUNDAY
this

It shows line which have the word sunday or monday irrespective of case in a file sample.dat

$ egrep -iw 'sunday|monday' sample.dat
sunday is holiday
monday
Sunday SUCCESS
SUNDAY 1234

It print all lines except sunday or monday occured lines in a file sample.dat, irrespective of case

$ egrep -iv 'sunday|monday' sample.dat
applas11i13
tuesday
wednesday
thursday
friday
saturday
SUUNDAY
this

It print all lines except the word sunday or monday occured lines in a file sample.dat, irrespective of case

$ egrep -iwv 'sunday|monday' sample.dat
applas11i13
tuesday
wednesday
thursday
friday
saturday
SUUNDAY
this





sort Command in Unix

The sort command sorts a file according to fields--the individual pieces of data on eachline. Sorting priority is number, upper-case, lower-case and symbol.

By default, sort assumes that the fields are just words separated by blanks

Syntax : sort <flags> <sort fields> <file name>
The most common flags are as follows:


Options Descriptions
-n Sort numerically, Ignore blanks and tabs
-r Reverse the order of sort
-f Sort upper and lowercase together
+x Ignore first x fields when sorting


Specify the sort keys like this:

+m   Start at the first character of the m+1th field.
-n     end at the last character of the nth field (if -N omitted, assume the end of the line).
-t      delimeter keys
-k1,2 field1 in primary key,filed2 is secondary key


Examples :

File name : example_sort.dat


g hi 123 liead
a bc 987 asd
d ef 873 lpoae
m no 873 apoie
j kl 234 ppoasd



sort the file ascending order
$ sort example_sort.dat
a bc 987 asd
d ef 873 lpoae
g hi 123 liead
j kl 234 ppoasd
m no 873 apoie



numeric sort the file using field3

$ sort -n -k3 example_sort.dat
g hi 123 liead
j kl 234 ppoasd
d ef 873 lpoae
m no 873 apoie
a bc 987 asd

tab delimiter [ctrl+v+TAB] sort the file using field2

$ sort -t"      " -k2 example_sort.dat
a bc 987 asd
d ef 873 lpoae
g hi 123 liead
j kl 234 ppoasd
m no 873 apoie

reverse sort

$ sort -r  example_sort.dat
m no 873 apoie
j kl 234 ppoasd
g hi 123 liead
d ef 873 lpoae
a bc 987 asd

sorted datas stored into another file

$ sort  example_sort.dat > example.sorted

$ cat example.sorted
a bc 987 asd
d ef 873 lpoae
g hi 123 liead
j kl 234 ppoasd
m no 873 apoie

cut field3 and apply numeric sort

$ cut -d"       " -f3 example_sort.dat |sort -n
123
234
873
873
987

cut field3 and apply numeric sort & eliminate duplicate values

$ cut -d"       " -f3 example_sort.dat |sort -n|uniq -u
123
234
873
987

EBS Order Holds details and release responsibility

  SELECT ooh.order_number,                  ooh.ordered_date,                 ooh.flow_status_code,                 ooh.credit_card_approval...