Sponsored Content
Top Forums Shell Programming and Scripting Putting a separator in file using awk/bash Post 302844008 by askerbis on Friday 16th of August 2013 05:32:48 AM
Old 08-16-2013
Putting a separator in file using awk/bash

I have a file with the following content:
Code:
a-123-345-232
a-23343-4545-545
a-67676-45454-8787
a-129-8912-9824
b-564-78678-2322
b-5454-76767-8899
b-85554-124-152-29
c-34534-654543-323

(... and so on, actually these are pretty huge records)
Now, I want that the file should not be broken in to multiple files but instead, a delimiter, say "#"should be inserted after all lines with beginning with "a" end again after the lines starting with "b" end and so on...

for example,
Code:
a-123-345-232
a-23343-4545-545
a-67676-45454-8787
a-129-8912-9824
#
b-564-78678-2322
b-5454-76767-8899
b-85554-124-152-29
#
c-34534-654543-323

Thanks....

Last edited by Scrutinizer; 08-16-2013 at 07:24 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk spliting using separator

Hi I have a file which looks like this #HEllo #How.... #version 1.0.1 #Author aaaaa ab.-.1.-.90.-.80.-..-.OK cd.-.8.-.91.-.800.-.xy.-..-. the separator is .-. (dot hyphen dot) I want to display this as columns like ab cd 1 8 90 91 (1 Reply)
Discussion started by: PrasannaKS
1 Replies

2. Shell Programming and Scripting

Field separator in awk

Hi I need to check if field separator I am using in awk statement is " : ", for example: TIME=12:59 HOUR=`echo "$TIME" | awk '{FS=":"; print $1}'` MINUTES=`echo "$TIME" | awk '{FS=":"; print $2}'` Is there a way to check within the above awk statement ? Thanks for help -A (2 Replies)
Discussion started by: aoussenko
2 Replies

3. Shell Programming and Scripting

Putting values into order in a field using awk

Hi, I am using UBUNTU 12.04. I have a dataset as follows: Column#1 Column#2 Column#3 .... Column#50 1 154878 1 145145 2 189565 2 454121 ... (5 Replies)
Discussion started by: Homa
5 Replies

4. Shell Programming and Scripting

awk field separator

I need to set awk field separator to ";", but I need to avoid ";EXT". so that echo a;b;c;EXTd;e;f | awk -F";" '{print $3}' would give "c;EXTd" (2 Replies)
Discussion started by: locoroco
2 Replies

5. Programming

Putting bash script in C program

suppose i have a bash script: #!/bin/bash echo "hello" echo "how are you" echo "today" how can i put the entire script above into a basic c program? i do not want to translate the bash code to a c code. i want C to run the bash code. is this possible? i found this on the... (15 Replies)
Discussion started by: SkySmart
15 Replies

6. Shell Programming and Scripting

awk field separator help -

Hi Experts , file : - How to construct the awk filed separator so that $1, $2 $3 , can be assigned to the each "" range. I am trying : awk -F"]" '{print $1}' but it is printing the entire file. Not first field. The desired output needed for first field... (9 Replies)
Discussion started by: rveri
9 Replies

7. Shell Programming and Scripting

Field Separator in printf (awk)

I can not figure out how to set the Output filed separator in awk when using printf. Example: cat file some data here_is_more information Requested output some------------data her_is_more-----information Here are some that does not work: awk '{printf "%-15s %s\n",$1,$2}' OFS="-" file... (9 Replies)
Discussion started by: Jotne
9 Replies

8. Shell Programming and Scripting

How to use variable as separator in awk?

can some give me a example ? eg: a=usb I want to use variable "a" as separator (2 Replies)
Discussion started by: yanglei_fage
2 Replies

9. Shell Programming and Scripting

Use string as Record separator in awk

Hello to all, Please some help on this. I have the file in format as below. How can I set the record separator as the string below in red "No. Time Source Destination Protocol Length Info" I've tried code below but it doesn't seem to... (6 Replies)
Discussion started by: cgkmal
6 Replies

10. Shell Programming and Scripting

Awk, with separator |

Friends have the following code that is correct. BEGIN { num_reg = 0 suma_iva=0 } { num_reg++ suma_iva=suma_iva+int(substr($0, 103,9)) } END{ printf ("%011d",suma_iva) } I have the following problem, I have to do just that but this time... (4 Replies)
Discussion started by: tricampeon81
4 Replies
Locale::Codes::LangFam(3)				User Contributed Perl Documentation				 Locale::Codes::LangFam(3)

NAME
Locale::Codes::LangFam - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangFam; $lext = code2langfam('apa'); # $lext gets 'Apache languages' $code = langfam2code('Apache languages'); # $code gets 'apa' @codes = all_langfam_codes(); @names = all_langfam_names(); DESCRIPTION
The "Locale::Codes::LangFam" module provides access to standard codes used for identifying language families, such as those as defined in ISO 639-5. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default ISO 639-5 language family codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language families. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langfam('apa','alpha'); $lext = code2langfam('apa',LOCALE_LANGFAM_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from ISO 639-5 such as 'apa' for Apache languages. This is the default code set. ROUTINES
code2langfam ( CODE [,CODESET] ) langfam2code ( NAME [,CODESET] ) langfam_code2code ( CODE ,CODESET ,CODESET2 ) all_langfam_codes ( [CODESET] ) all_langfam_names ( [CODESET] ) Locale::Codes::LangFam::rename_langfam ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangFam::add_langfam ( CODE ,NAME [,CODESET] ) Locale::Codes::LangFam::delete_langfam ( CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_alias ( NAME ,NEW_NAME ) Locale::Codes::LangFam::delete_langfam_alias ( NAME ) Locale::Codes::LangFam::rename_langfam_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::delete_langfam_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.loc.gov/standards/iso639-5/id.php ISO 639-5 . AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2013 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.3 2013-02-27 Locale::Codes::LangFam(3)
All times are GMT -4. The time now is 06:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy