I have a tab separated text file. Some rows have 10 columns and some rows have 11 columns. I want to add an extra column to the last of 10 column rows with the value 0. How can i do this?
How to append to the lines with fewer columns in a tab separated text file?
129 Views Asked by Ramin Zahedi At
2
There are 2 best solutions below
Related Questions in BASH
- How do I recursively find and replace only in files named index.php on Linux webserver?
- Delete the extra space after special character in all the lines of text file
- Calling a python function with options from shell script
- bc: prevent "divide by zero" runtime error on multiple operations
- Multiple commands with find and xargs, also accounting for special characters
- How to split a directory into parts without compressing or archiving?
- concat a lot of files to stdout
- Honoring quotes while reading shell arguments from a file
- No laravel sync folders in homestead vagrant on windows
- Grouping commands in curly braces and piping does not preserve variable
- SWI Prolog pass a goal with non-zero arity through the command line arguments
- Evaluating condition of if statement in awk using a second file
- How to customise bash completion to pick only a custom set of commands?
- Bash regular expression execution hangs on long expressions
- Bitwise OR in bash arguments with square brackets
Related Questions in TEXT
- Delete the extra space after special character in all the lines of text file
- Apply gaussian filter on text
- text show and hide with button php/js
- Get text from a section of a pdf page with IcePdf
- load word file (.docx) in richtextbox
- Display a specific line in a text file - android/java
- how to change text direction to the right slide of switch in android?
- C language - Read specific data from text file
- Read text file from specific position and store in two arrays
- How to animate text
- Detect repetition in text string / copied text
- Use MATLAB's webread to login to website and extract text
- LWJGL Drawing colored text to the screen issue
- Hide part of text temporarily, show after user clicks certain element
- Reading text file in java using scanner
Related Questions in AWK
- Delete the extra space after special character in all the lines of text file
- Evaluating condition of if statement in awk using a second file
- Awk syntax with printf - not desired format
- bash: read each line from a file and use as a regular expression to match and print column awk
- awk | Extract Log on the basis of Time
- Detecting corrupt characters in UTF-8 encoded text file
- Using sed to substitute in a single record
- How to filter data from flat file with multiply lines pattern using awk or sed tool?
- Sed replace string, based on input file
- Sorting unique elements column-wise in a text-file
- grep/sed replace no match with blank space
- how to break one column into multiple columns in Linux
- How to use a bash variable in this awk script
- How to create a new file where each new line contains some text and quoted line/step number?
- How to convert following text in required format in unix?
Related Questions in SED
- Delete the extra space after special character in all the lines of text file
- Using sed to substitute in a single record
- sed: make changes in the same file on Windows
- while read line out of scope
- Need to edit a line from particular section inside a file using sed in linux
- How to filter data from flat file with multiply lines pattern using awk or sed tool?
- Sed replace string, based on input file
- Sorting unique elements column-wise in a text-file
- grep/sed replace no match with blank space
- Edit huge sql data file
- Path of the current, parents and root directory
- Using sed, awk or grep to split a string with numbers
- Sed & Regex: match between two characters only sometimes successful
- convert first column from hex to decimal using awk
- Bash: Replace values of a column while retaining line order.
Related Questions in TEXT-PROCESSING
- PHP split string into known tokens and remaining words add to single-worded array
- C# implementation of Dictionary to Create an index of words
- Why this exclusion not working for long sentences?
- Omit words in a text
- Getting repeated lines with awk in Bash
- Algorithm to group parts of documents that belong together
- Text Processing - Converting fixed width text files to delimited
- How to append to the lines with fewer columns in a tab separated text file?
- identifying leading line space - shell script
- Count duplicates from several files
- Merge all .wav files in a folder that start by the same prefix
- How can I search a text file for Count specific words using matlab?
- Add filename before first occurrence of a character in all lines for all files in a given folder
- Put file names into text
- Replace date in a txt file having xml
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Since you have mentioned append, you can
awkas belowThe
-F $'\t'takes care of the tab-separation part,BEGIN {OFS = FS}for setting the output field separation.The
NF==10looks only for the lines having only 10 records and the{$0=$0"0"}1for reconstructing that line with the extra word added.To write to a separate file use the
>redirect operator asTo replace the original file use
mvOr if you have latest
GNU Awk(since4.1.0released), it has the option of "inplace" file editing: