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?
132 views Asked by Ramin Zahedi At
2
There are 2 answers
Related Questions in BASH
- When does Bash read heredocs?
- Why `set -o pipefail` gives different output even though the pipe is not failing
- Run an external command within jq to manipulate each values of a particular key
- API key 401 error in .env.development file
- How to "Enable mobile data" on a Huawei E3372 4G USB dongle using a bash script in Windows
- ImageMagick / Bash : pipe ignored(?) when filename format variable used
- MacOS Bash-Script: while read p and echo
- Parse command line arguments and write useful usage message without additional code
- JQ JSON - Values to Array
- why variable substitution is so different?
- postbank_pdf2csv: how to setup with Cygwin in Windows?
- Custom Bash functions & custom statements - Need some advice
- unexpected operator == in square brackets when trying to use gum lib
- How to disable a bash builtin inside a docker container
- Use sed or rename find series of alphabet then replace with with the same alphabet and a dash -
Related Questions in TEXT
- Seeking Python Libraries for Removing Extraneous Characters and Spaces in Text
- How to increase quality of mathjax output?
- How to appropriately handle newlines and the escaping of them?
- How to store data with lots of subdata but keep easy and simple access in python
- Can I make this kind of radio button?
- I am findind it dificult to create a box containing text
- Replacing Text using Javascript
- How to set text inside a div using JavaScript and CSS
- How to get new text input after entering a password in a tab?
- How can I get my hero section to look like this?
- Find text and numbers Formatted: "Case: BE########" and format them, regardless of the number
- Auto style text in flutter
- Text analytics and Insights
- Combine an audio and a text file as one single file
- How to align side text and table horizontally in R-markdown
Related Questions in AWK
- Extract multiple strings from a multiple lines text file - an extra rule and larger test file
- Split with multiple delimiters and swap words using awk
- Extract multiple strings from a multiple lines text file - larger test file
- Extract multiple strings from a multiple lines text file
- Process the latest version of a file ..... as the 2nd file of a pair of files that are to be processed
- Awk print a value in a column that corresponds to key values
- awk ward gps monitoring
- How to get a list of numbers out of an awk output in bash
- Awk switching output field seperator depending on the line length
- AWK or sed to print data in table format
- adding text and inserting a literal slash between two columns
- Copying the fields of one record into the fields of another record in a second file with awk
- best method to improve awk speed in writing to sqlite3 db
- convert sprintf() statement to printf() statement in awk
- print lines with blank spaces or white spaces
Related Questions in SED
- Use sed or rename find series of alphabet then replace with with the same alphabet and a dash -
- Delete first three lines containing a certain word
- How to use a loop to chain piped commands together?
- Executing sed from php script
- Sed bash replace containing a path pattern
- Order of options in Unix sed for editing files in-place
- How to change urlencode spaces inside a sed capture group only?
- How to use a variable command in a sed expression
- sed search and replace with spaces
- Can you replace a substring from a regex match?
- Truncating "wrapping" long string outputs with prefix, appends new line at the bottom of each dump of the hold space
- AWK or sed to print data in table format
- print lines with blank spaces or white spaces
- How to use sed in shell script with value containing line break \n?
- Replace the values under some columns using awk or sed
Related Questions in TEXT-PROCESSING
- Seeking Python Libraries for Removing Extraneous Characters and Spaces in Text
- Why is my Python script not calling GPT-3.5-turbo API?
- How to properly decode the image from encoded image text from a live ANPR Camera stream?
- Return sentences from list of sentences using user specified keyword
- Determining the type of error and its place in the text
- Implementing Automatic Syllable Splitting and Coloring in a Flutter App
- how to use jq to print one-line per root-level object key?
- how to use jq to print JSON array elements separated by tabs "\t"
- How to print specific values of the etherscan API output with python
- Awk: set RS to include newline and 1st (only) field of next row // logfile "splits" based on custom RS and print matching pattern therein
- How to Create a Comprehensive Character Mapping from Regular to Bold Text in JavaScript, Similar to YayText?
- Split address text into components using Machine Learning
- Designing two programs to accomplish a text-processing task on Windows
- awk find/print paragraph containing multiple patterns
- Extract N lines with no duplicate strings from either of the two first columns
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?
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)
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: