Sponsored Content
Top Forums Shell Programming and Scripting Awk, sed, shell all words in INPUT.txt find in column1 of TABLE.txt and replce with column2 in Post 303011974 by Don Cragun on Friday 26th of January 2018 08:36:43 PM
Old 01-26-2018
One might also consider explaining how the 3rd column in TABLE.txt is supposed to be used.

It appears that you want ]/.xori to be translated to word4, but column 2 in TABLE.txt on the line with ]/.xori has word in column 2 on that line and 4 in column 3; not word4, Your description didn't say anything about a column 3 in TABLE.txt. Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed to read x.txt and grep from y.txt

How would I write a command(s) to read from a file (list) that looks like this: 29847374384 and grep from a second file (list) that looks like this: 29847374384, jkdfkjdf,3833,ddd:confused: (1 Reply)
Discussion started by: smellylizzard
1 Replies

2. UNIX for Dummies Questions & Answers

find lines in file1.txt not found in file2.txt memory problem

I have a diff command that does what I want but when comparing large text/log files, it uses up all the memory I have (sometimes over 8gig of memory) diff file1.txt file2.txt | grep '^<'| awk '{$1="";print $0}' | sed 's/^ *//' Is there a better more efficient way to find the lines in one file... (5 Replies)
Discussion started by: raptor25
5 Replies

3. Shell Programming and Scripting

Convert shell script output txt file to html table

Hi, I have script which generates the output as below: Jobname Date Time Status abc 12/9/11 17:00 Completed xyz 13/9/11 21:00 Running I have the output as a text file. I need to convert it into a HTML Table and sent it thru email ... (6 Replies)
Discussion started by: a12ka4
6 Replies

4. Shell Programming and Scripting

awk append fileA.txt to growing file B.txt

This is appending a column. My question is fairly simple. I have a program generating data in a form like so: 1 20 2 22 3 23 4 12 5 43 For ever iteration I'm generating this data. I have the basic idea with cut -f 2 fileA.txt | paste -d >> FileB.txt ???? I want FileB.txt to grow, and... (4 Replies)
Discussion started by: theawknewbie
4 Replies

5. UNIX for Dummies Questions & Answers

How to Update DB table from txt file using CRONJOB in Unix Shell Script

Hi Experts, can guide how we can Update a Database Table using a txt file source Using Unix Shell Scripts. What are the Cron Jobs codes can written to Update DB table. txt file contains record like data. US 09/03/2012 User DocType DocID. these above feilds in txt files need to be updated in... (4 Replies)
Discussion started by: mahesh.sap
4 Replies

6. Shell Programming and Scripting

Read input txt while find copy

I have a text file called file.txt which has a list of file as shown below that i need to find and copy to a particular location. FILENAMES skter.pdf abcdf.sas tereen.lst abc12.txt i am using following code and it never works however i try it. cat file.txt | while read FILENAME;do find... (4 Replies)
Discussion started by: MILAN KUMAR
4 Replies

7. Shell Programming and Scripting

Desired output.txt for reading txt file using awk?

Dear all, I have a huge txt file (DATA.txt) with the following content . From this txt file, I want the following output using some shell script. Any help is greatly appreciated. Greetings, emily DATA.txt (snippet of the huge text file) 407202849... (2 Replies)
Discussion started by: emily
2 Replies

8. Shell Programming and Scripting

Convert shell script output txt file to html table

My concnern related to the post -Convert shell script output txt file to html table, in this how to print the heading as color. awk 'BEGIN{print "<table>"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"} END{print "</table>"}' <filename> (8 Replies)
Discussion started by: sarajobmai
8 Replies

9. Shell Programming and Scripting

How to get the shell script to read the .txt file as an input/data?

i have written my shell script in notepad however i am struggling to pass the data file to be read to the script the data file is of .txt format. My target is to run the shell script from the terminal and pass 3 arguments e.g. polg@DESKTOP-BVPDC5C:~/CS1420/coursework$ bash valsplit.sh input.txt... (11 Replies)
Discussion started by: Gurdza32
11 Replies

10. Shell Programming and Scripting

Search last column of INPUT.txt in TABLEs text and add correspond columns to INPUT.txt

Hi dears i use bash shell i have INPUT.txt like this number of columns different in one some row have 12 , some 11 columns see last column INPUT.txt CodeGender Age Grade Dialect Session Sentence Start End Length Phonemic Phonetic 63 M 27 BS/BA TEHRANI 3 4 298320 310050... (2 Replies)
Discussion started by: alii
2 Replies
ALTER 
TABLE(7) SQL Commands ALTER TABLE(7) NAME
ALTER TABLE - change the definition of a table SYNOPSIS
ALTER TABLE [ ONLY ] table [ * ] ADD [ COLUMN ] column type [ column_constraint [ ... ] ] ALTER TABLE [ ONLY ] table [ * ] DROP [ COLUMN ] column [ RESTRICT | CASCADE ] ALTER TABLE [ ONLY ] table [ * ] ALTER [ COLUMN ] column { SET DEFAULT value | DROP DEFAULT } ALTER TABLE [ ONLY ] table [ * ] ALTER [ COLUMN ] column { SET | DROP } NOT NULL ALTER TABLE [ ONLY ] table [ * ] ALTER [ COLUMN ] column SET STATISTICS integer ALTER TABLE [ ONLY ] table [ * ] ALTER [ COLUMN ] column SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN } ALTER TABLE [ ONLY ] table [ * ] RENAME [ COLUMN ] column TO new_column ALTER TABLE table RENAME TO new_table ALTER TABLE [ ONLY ] table [ * ] ADD table_constraint ALTER TABLE [ ONLY ] table [ * ] DROP CONSTRAINT constraint_name [ RESTRICT | CASCADE ] ALTER TABLE table OWNER TO new_owner INPUTS table The name (possibly schema-qualified) of an existing table to alter. If ONLY is specified, only that table is altered. If ONLY is not specified, the table and all its descendant tables (if any) are updated. * can be appended to the table name to indicate that descendant tables are to be scanned, but in the current version, this is the default behavior. (In releases before 7.1, ONLY was the default behavior.) The default can be altered by changing the SQL_INHERITANCE configuration option. column Name of a new or existing column. type Type of the new column. new_column New name for an existing column. new_table New name for the table. table_constraint New table constraint for the table. constraint_name Name of an existing constraint to drop. new_owner The user name of the new owner of the table. CASCADE Automatically drop objects that depend on the dropped column or constraint (for example, views referencing the column). RESTRICT Refuse to drop the column or constraint if there are any dependent objects. This is the default behavior. OUTPUTS ALTER TABLE Message returned from column or table renaming. ERROR Message returned if table or column is not available. DESCRIPTION
ALTER TABLE changes the definition of an existing table. There are several sub-forms: ADD COLUMN This form adds a new column to the table using the same syntax as CREATE TABLE [create_table(7)]. DROP COLUMN This form drops a column from a table. Note that indexes and table constraints involving the column will be automatically dropped as well. You will need to say CASCADE if anything outside the table depends on the column --- for example, foreign key references, views, etc. SET/DROP DEFAULT These forms set or remove the default value for a column. Note that defaults only apply to subsequent INSERT commands; they do not cause rows already in the table to change. Defaults may also be created for views, in which case they are inserted into INSERT statements on the view before the view's ON INSERT rule is applied. SET/DROP NOT NULL These forms change whether a column is marked to allow NULL values or to reject NULL values. You may only SET NOT NULL when the ta- ble contains no null values in the column. SET STATISTICS This form sets the per-column statistics-gathering target for subsequent ANALYZE [analyze(7)] operations. The target can be set in the range 0 to 1000; alternatively, set it to -1 to revert to using the system default statistics target. SET STORAGE This form sets the storage mode for a column. This controls whether this column is held inline or in a supplementary table, and whether the data should be compressed or not. PLAIN must be used for fixed-length values such as INTEGER and is inline, uncom- pressed. MAIN is for inline, compressible data. EXTERNAL is for external, uncompressed data and EXTENDED is for external, compressed data. EXTENDED is the default for all data types that support it. The use of EXTERNAL will make substring operations on a TEXT col- umn faster, at the penalty of increased storage space. RENAME The RENAME forms change the name of a table (or an index, sequence, or view) or the name of an individual column in a table. There is no effect on the stored data. ADD table_constraint This form adds a new constraint to a table using the same syntax as CREATE TABLE [create_table(7)]. DROP CONSTRAINT This form drops constraints on a table. Currently, constraints on tables are not required to have unique names, so there may be more than one constraint matching the specified name. All such constraints will be dropped. OWNER This form changes the owner of the table, index, sequence or view to the specified user. You must own the table to use ALTER TABLE; except for ALTER TABLE OWNER, which may only be executed by a superuser. NOTES The keyword COLUMN is noise and can be omitted. In the current implementation of ADD COLUMN, default and NOT NULL clauses for the new column are not supported. The new column always comes into being with all values NULL. You can use the SET DEFAULT form of ALTER TABLE to set the default afterwards. (You may also want to update the already existing rows to the new default value, using UPDATE [update(7)].) If you want to mark the column non-null, use the SET NOT NULL form after you've entered non-null values for the column in all rows. The DROP COLUMN command does not physically remove the column, but simply makes it invisible to SQL operations. Subsequent inserts and updates of the table will store a NULL for the column. Thus, dropping a column is quick but it will not immediately reduce the on-disk size of your table, as the space occupied by the dropped column is not reclaimed. The space will be reclaimed over time as existing rows are updated. To reclaim the space at once, do a dummy UPDATE of all rows and then vacuum, as in: UPDATE table SET col = col; VACUUM FULL table; If a table has any descendant tables, it is not permitted to ADD or RENAME a column in the parent table without doing the same to the descendants --- that is, ALTER TABLE ONLY will be rejected. This ensures that the descendants always have columns matching the parent. A recursive DROP COLUMN operation will remove a descendant table's column only if the descendant does not inherit that column from any other parents and never had an independent definition of the column. A nonrecursive DROP COLUMN (i.e., ALTER TABLE ONLY ... DROP COLUMN) never removes any descendant columns, but instead marks them as independently defined rather than inherited. Changing any part of the schema of a system catalog is not permitted. Refer to CREATE TABLE for a further description of valid arguments. The PostgreSQL User's Guide has further information on inheritance. USAGE
To add a column of type varchar to a table: ALTER TABLE distributors ADD COLUMN address VARCHAR(30); To drop a column from a table: ALTER TABLE distributors DROP COLUMN address RESTRICT; To rename an existing column: ALTER TABLE distributors RENAME COLUMN address TO city; To rename an existing table: ALTER TABLE distributors RENAME TO suppliers; To add a NOT NULL constraint to a column: ALTER TABLE distributors ALTER COLUMN street SET NOT NULL; To remove a NOT NULL constraint from a column: ALTER TABLE distributors ALTER COLUMN street DROP NOT NULL; To add a check constraint to a table: ALTER TABLE distributors ADD CONSTRAINT zipchk CHECK (char_length(zipcode) = 5); To remove a check constraint from a table and all its children: ALTER TABLE distributors DROP CONSTRAINT zipchk; To add a foreign key constraint to a table: ALTER TABLE distributors ADD CONSTRAINT distfk FOREIGN KEY (address) REFERENCES addresses(address) MATCH FULL; To add a (multicolumn) unique constraint to a table: ALTER TABLE distributors ADD CONSTRAINT dist_id_zipcode_key UNIQUE (dist_id, zipcode); To add an automatically named primary key constraint to a table, noting that a table can only ever have one primary key: ALTER TABLE distributors ADD PRIMARY KEY (dist_id); COMPATIBILITY
SQL92 The ADD COLUMN form is compliant with the exception that it does not support defaults and NOT NULL constraints, as explained above. The ALTER COLUMN form is in full compliance. The clauses to rename tables, columns, indexes, and sequences are PostgreSQL extensions from SQL92. SQL - Language Statements 2002-11-22 ALTER TABLE(7)
All times are GMT -4. The time now is 06:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy