Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

I would manipulate the contents of the second column based on the number of colons it contains. If the second field contains more than one colon then I would require the content before first colon else I would require entire value.

#Input    
1 1131:11854476:4:1$ 0 114476 1 4
5 367504:11862778:4:2$ 0 118628 2 4
3 3:64357_3_2$ 0 18267 2 3 
4 7575:38680372:1$ 0 38372 1 2

# Output
1 1131 0 114476 1 4
5 367504 0 118628 2 4
3 3:64357_3_2$ 0 18267 2 3 
4 7575 0 386372 1 2

I have come across different suggestions to copy a single column after manipulating or processing entire file/stringstring but I would need to retain the remaining columns unprocessed. Could you please give ideas on how to achieve this in a single command (awk/cut one-liners) or multiple commands.

I would manipulate the contents of the second column based on the number of colons it contains. If the second field contains more than one colon then I would require the content before first colon else I would require entire value.

#Input    
1 1131:11854476:4:1$ 0 114476 1 4
5 367504:11862778:4:2$ 0 118628 2 4
3 3:64357_3_2$ 0 18267 2 3 
4 7575:38680372:1$ 0 38372 1 2

# Output
1 1131 0 114476 1 4
5 367504 0 118628 2 4
3 3:64357_3_2$ 0 18267 2 3 
4 7575 0 386372 1 2

I have come across different suggestions to copy a single column after manipulating or processing entire file/string but I would need to retain the remaining columns unprocessed. Could you please give ideas on how to achieve this in a single command (awk/cut one-liners) or multiple commands.

I would manipulate the contents of the second column based on the number of colons it contains. If the second field contains more than one colon then I would require the content before first colon else I would require entire value.

#Input    
1 1131:11854476:4:1$ 0 114476 1 4
5 367504:11862778:4:2$ 0 118628 2 4
3 3:64357_3_2$ 0 18267 2 3 
4 7575:38680372:1$ 0 38372 1 2

# Output
1 1131 0 114476 1 4
5 367504 0 118628 2 4
3 3:64357_3_2$ 0 18267 2 3 
4 7575 0 386372 1 2

I have come across different suggestions to copy a single column after manipulating or processing entire file/string but I would need to retain the remaining columns unprocessed. Could you please give ideas on how to achieve this in a single command (awk/cut one-liners) or multiple commands.

added 7 characters in body; edited tags; edited title
Source Link
don_crissti
  • 85.6k
  • 31
  • 234
  • 262

extract part of Modify values in a column based on specific patternnumber of delimiterscolons it contains

I would manipulate the contents of the second column based on the delimitersnumber of colons it contains. If it has delimiter colon followed by anotherthe second field contains more than one colon then I would require the content before first stringcolon else I would require entire value.

#Input    
1 1131:11854476:4:1$ 0 114476 1 4
5 367504:11862778:4:2$ 0 118628 2 4
3 3:64357_3_2$ 0 18267 2 3 
4 7575:38680372:1$ 0 38372 1 2

# Output
1 1131 0 114476 1 4
5 367504 0 118628 2 4
3 3:64357_3_2$ 0 18267 2 3 
4 7575 0 386372 1 2

I have come across different suggestions to copy a single column after manipulating or processing entire file/string but I would need to retain the remaining columns unprocessed. Could you please give ideas on how to achieve this in a single command  (awkawk/cutcut one-liners) or multiple commands.

extract part of a column based on specific pattern of delimiters

I would manipulate the contents of the second column based on the delimiters it contains. If it has delimiter colon followed by another colon then I would require the content before first string else I would require entire value.

#Input    
1 1131:11854476:4:1$ 0 114476 1 4
5 367504:11862778:4:2$ 0 118628 2 4
3 3:64357_3_2$ 0 18267 2 3 
4 7575:38680372:1$ 0 38372 1 2

# Output
1 1131 0 114476 1 4
5 367504 0 118628 2 4
3 3:64357_3_2$ 0 18267 2 3 
4 7575 0 386372 1 2

I have come across different suggestions to copy a single column after manipulating or processing entire file/string but I would need to retain the remaining columns unprocessed. Could you please give ideas on how to achieve this in a single command(awk/cut one-liners) or multiple commands.

Modify values in a column based on number of colons it contains

I would manipulate the contents of the second column based on the number of colons it contains. If the second field contains more than one colon then I would require the content before first colon else I would require entire value.

#Input    
1 1131:11854476:4:1$ 0 114476 1 4
5 367504:11862778:4:2$ 0 118628 2 4
3 3:64357_3_2$ 0 18267 2 3 
4 7575:38680372:1$ 0 38372 1 2

# Output
1 1131 0 114476 1 4
5 367504 0 118628 2 4
3 3:64357_3_2$ 0 18267 2 3 
4 7575 0 386372 1 2

I have come across different suggestions to copy a single column after manipulating or processing entire file/string but I would need to retain the remaining columns unprocessed. Could you please give ideas on how to achieve this in a single command  (awk/cut one-liners) or multiple commands.

linked the question for previous reference in the text
Source Link
Prradep
  • 203
  • 2
  • 12

I would manipulate the contents of the second column based on the delimiters it contains. If it has delimiter colon followed by another colon then I would require the content before first string else I would require entire value.

#Input    
1 1131:11854476:4:1$ 0 114476 1 4
5 367504:11862778:4:2$ 0 118628 2 4
3 3:64357_3_2$ 0 18267 2 3 
4 7575:38680372:1$ 0 38372 1 2

# Output
1 1131 0 114476 1 4
5 367504 0 118628 2 4
3 3:64357_3_2$ 0 18267 2 3 
4 7575 0 386372 1 2

I have come across different suggestions to copy a single column after manipulating or processing entire file/string but I would need to retain the remaining columns unprocessed. Could you please give ideas on how to achieve this in a single command(awk/cut one-liners) or multiple commands.

I would manipulate the contents of the second column based on the delimiters it contains. If it has delimiter colon followed by another colon then I would require the content before first string else I would require entire value.

#Input    
1 1131:11854476:4:1$ 0 114476 1 4
5 367504:11862778:4:2$ 0 118628 2 4
3 3:64357_3_2$ 0 18267 2 3 
4 7575:38680372:1$ 0 38372 1 2

# Output
1 1131 0 114476 1 4
5 367504 0 118628 2 4
3 3:64357_3_2$ 0 18267 2 3 
4 7575 0 386372 1 2

I have come across different suggestions to copy a single column after manipulating or processing entire file but I would need to retain the remaining columns unprocessed. Could you please give ideas on how to achieve this in a single command(awk/cut one-liners) or multiple commands.

I would manipulate the contents of the second column based on the delimiters it contains. If it has delimiter colon followed by another colon then I would require the content before first string else I would require entire value.

#Input    
1 1131:11854476:4:1$ 0 114476 1 4
5 367504:11862778:4:2$ 0 118628 2 4
3 3:64357_3_2$ 0 18267 2 3 
4 7575:38680372:1$ 0 38372 1 2

# Output
1 1131 0 114476 1 4
5 367504 0 118628 2 4
3 3:64357_3_2$ 0 18267 2 3 
4 7575 0 386372 1 2

I have come across different suggestions to copy a single column after manipulating or processing entire file/string but I would need to retain the remaining columns unprocessed. Could you please give ideas on how to achieve this in a single command(awk/cut one-liners) or multiple commands.

added the missing character
Source Link
Prradep
  • 203
  • 2
  • 12
Loading
Source Link
Prradep
  • 203
  • 2
  • 12
Loading