Sponsored Content
Top Forums Shell Programming and Scripting Replace a column with a value by ignoring the header lines Post 302785277 by anbu23 on Monday 25th of March 2013 07:38:27 AM
Old 03-25-2013
Code:
$ cat file
< Aravind, 33, chennai, 09091980, , , , , , , surfing>
< Swapnil, 32, bhopal, 01121981, , , , , , , cricket>
$ awk '{sub(".{8}","********",$5)}1' file
< Aravind, 33, chennai, ********, , , , , , , surfing>
< Swapnil, 32, bhopal, ********, , , , , , , cricket>

Code:
$ cat file
< Aravind,33,chennai,09091980, , , , , , , surfing>
< Swapnil,32,bhopal,01121981, , , , , , , cricket>
$ awk -F"," -v OFS="," '{sub(".{8}","********",$4)}1' file
< Aravind,33,chennai,********, , , , , , , surfing>
< Swapnil,32,bhopal,********, , , , , , , cricket>

Redirect the output of awk to same file and then gzip it.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to count lines - ignoring blank lines and commented lines

What is the command to count lines in a files, but ignore blank lines and commented lines? I have a file with 4 sections in it, and I want each section to be counted, not including the blank lines and comments... and then totalled at the end. Here is an example of what I would like my... (6 Replies)
Discussion started by: kthatch
6 Replies

2. Shell Programming and Scripting

awk/sed column replace using column header - help

$ cat log.txt Name Age Sex Lcation nfld alias xsd CC 25 M XYZ asx KK Y BB 21 F XAS awe SS N SD 21 M AQW rty SD A How can I replace the column with header "Lcation" with the column with header "alias" and delete the "alias" column? so that the final output will become: Name Age Sex... (10 Replies)
Discussion started by: jkl_jkl
10 Replies

3. UNIX for Dummies Questions & Answers

deleteing duplicate lines sing uniq while ignoring a column

I have a data set that has 4 columns, I want to know if I can delete duplicate lines while ignoring one of the columns, for example 10 chr1 ASF 30 15 chr1 ASF 20 5 chr1 ASF 30 6 chr2 EBC 15 4 chr2 EBC 30 ... I want to know if I can delete duplicate lines while ignoring column 1, so the... (5 Replies)
Discussion started by: japaneseguitars
5 Replies

4. Shell Programming and Scripting

Rename a header column by adding another column entry to the header column name URGENT!!

Hi All, I have a file example.csv which looks like this GrpID,TargetID,Signal,Avg_Num CSCH74_1_1,2007,61,256 CSCH74_1_1,212007,647,679 CSCH74_1_1,12007,3,32 CSCH74_1_1,207,299,777 I want the output as GrpID,TragetID,Signal-CSCH74_1_1,Avg_Num CSCH74_1_1,2007,61,256... (4 Replies)
Discussion started by: Vavad
4 Replies

5. UNIX for Dummies Questions & Answers

Rename a header column by adding another column entry to the header column name

Hi All, I have a file example.csv which looks like this GrpID,TargetID,Signal,Avg_Num CSCH74_1_1,2007,61,256 CSCH74_1_1,212007,647,679 CSCH74_1_1,12007,3,32 CSCH74_1_1,207,299,777 I want the output as GrpID,TragetID,Signal-CSCH74_1_1,Avg_Num CSCH74_1_1,2007,61,256... (1 Reply)
Discussion started by: Vavad
1 Replies

6. UNIX for Dummies Questions & Answers

Merge all csv files in one folder considering only 1 header row and ignoring header of all others

Friends, I need help with the following in UNIX. Merge all csv files in one folder considering only 1 header row and ignoring header of all other files. FYI - All files are in same format and contains same headers. Thank you (4 Replies)
Discussion started by: Shiny_Roy
4 Replies

7. Shell Programming and Scripting

Add column header and row header

Hi, I have an input like this 1 2 3 4 2 3 4 5 4 5 6 7 I would like to count the no. of columns and print a header with a prefix "Col". I would also like to count the no. of rows and print as first column with each line number with a prefix "Row" So, my output would be ... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

8. Shell Programming and Scripting

Sum of a column as new column based on header in a script

Hello, I am trying to store sum of a column as a new column inside a file but have to find the column names dynamically I/p c1,c2,c3,c4,c5 10,20,30,40,50 20,30,40,50,60 If i want to find sum only column c1, c3 and output it as c6,c7 O/p c1,c2,c3,c4,c5,c6,c7 10,20,30,40,50,30,70... (6 Replies)
Discussion started by: mkathi
6 Replies

9. UNIX for Beginners Questions & Answers

awk script to extract a column, replace one of the header and replace year(from ddmmyy to yyyy)

I have a csv which has lot of columns . I was looking for an awk script which would extract a column twice. for the first occurance the header and data needs to be intact but for the second occurance i want to replace the header name since it a duplicate and extract year value which is in ddmmyy... (10 Replies)
Discussion started by: Kunalcurious
10 Replies

10. Shell Programming and Scripting

Find header in a text file and prepend it to all lines until another header is found

I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty. I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the... (3 Replies)
Discussion started by: verdepollo
3 Replies
git-annex-shell(1)					      General Commands Manual						git-annex-shell(1)

NAME
git-annex-shell - Restricted login shell for git-annex only SSH access SYNOPSIS
git-annex-shell [-c] command [params ...] DESCRIPTION
git-annex-shell is a restricted shell, similar to git-shell, which can be used as a login shell for SSH accounts. Since its syntax is identical to git-shell's, it can be used as a drop-in replacement anywhere git-shell is used. For example it can be used as a user's restricted login shell. COMMANDS
Any command not listed below is passed through to git-shell. Note that the directory parameter should be an absolute path, otherwise it is assumed to be relative to the user's home directory. Also the first "/~/" or "/~user/" is expanded to the specified home directory. configlist directory This outputs a subset of the git configuration, in the same form as git config --list inannex directory [key ...] This checks if all specified keys are present in the annex, and exits zero if so. dropkey directory [key ...] This drops the annexed data for the specified keys. recvkey directory key This runs rsync in server mode to receive the content of a key, and stores the content in the annex. sendkey directory key This runs rsync in server mode to transfer out the content of a key. commit directory This commits any staged changes to the git-annex branch. It also runs the annex-content hook. OPTIONS
Most options are the same as in git-annex. The ones specific to git-annex-shell are: --uuid=UUID git-annex uses this to specify the UUID of the repository it was expecting git-annex-shell to access, as a sanity check. HOOK
After content is received or dropped from the repository by git-annex-shell, it runs a hook, .git/hooks/annex-content (or hooks/annex-con- tent on a bare repository). The hook is not currently passed any information about what changed. ENVIRONMENT
GIT_ANNEX_SHELL_READONLY If set, disallows any command that could modify the repository. GIT_ANNEX_SHELL_LIMITED If set, disallows running git-shell to handle unknown commands. SEE ALSO
git-annex(1) git-shell(1) AUTHOR
Joey Hess <joey@kitenet.net> <http://git-annex.branchable.com/> git-annex-shell(1)
All times are GMT -4. The time now is 08:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy