Sponsored Content
Top Forums Shell Programming and Scripting Add delimiter to a file from layout file Post 302973080 by RudiC on Friday 13th of May 2016 04:21:01 PM
Old 05-13-2016
Try this pure shell (bash):
Code:
while IFS=" 	(:)" read _ _ P _ _ L; do ((IX++)); POS[$IX]=$((P-1)); LEN[$IX]=$L; done < layout.txt

while read T
  do    unset CRS L
        for i in ${!POS[@]}
          do    L=$L${T:$CRS:$((${POS[$i]}-CRS))}"~"${T:${POS[$i]}:${LEN[$i]}}"~"
                CRS=$((${POS[$i]}+${LEN[$i]}))
          done
        L=${L#\~}
        L=${L//~~/\~}
        L=$L${T:$CRS}
        printf "%s\n" $L
  done < abc.txt
11~01~0116~03~15100000000000000
11~01~0116~03~15100000000000000


Last edited by RudiC; 05-16-2016 at 05:48 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

splitting file with more than one delimiter

Hi, I just wandering how to split a record which has more than one delimiter, i have a file which contains pattern as group separtor and ~ as field separtor, Ultimately I need consider even the groups as a field, So i need to make this multi-delimited file into ~ delimited file. My record... (4 Replies)
Discussion started by: braindrain
4 Replies

2. Shell Programming and Scripting

extracting delimiter from a file.

hi, pls someone tell me how to extract delimiters from any file and pass it to a unix script.since, im a beginner in unix i find it little bit difficult.how to use awk to do this? (9 Replies)
Discussion started by: sureshmit
9 Replies

3. UNIX for Dummies Questions & Answers

How to change delimiter in my file ?

Hi I have a file in which delimiter is ';' However if the delimiter is within "" it is a part of the string and not delimiter. How to get the fields ? I want to replace the delimiter ';' to '|'. The file contains data like this : 11111; “2222 2222”; “3333; 3333”; “4444 ""44444” The file... (2 Replies)
Discussion started by: dashing201
2 Replies

4. Shell Programming and Scripting

Creating delimiter file

#/bin/sh sysdate=`date +"%m/%d/%Y"` systime=`date +%r` ps_per=`lsps -s | nawk '{print $2+0}'|tail -1` ps_tot=`lsps -s | nawk '{print $1+0}'|tail -1` lcpu=`vmstat | nawk -F= '/lcpu/ {print $2+0}'` mem_tot=`vmstat | nawk -F= '/mem=/ {print $3+0}'` avm=`vmstat|awk '{print... (7 Replies)
Discussion started by: Daniel Gate
7 Replies

5. Shell Programming and Scripting

Delimiter in output file

Hello, I am trying to find the record count in a specific folder, Here is the part of the code =========================== STARTDATE=`date +"%y%m%d%H%M"` for i in `ls *.DAT` do wc -l $i >> /XYZ/SrcFiles/"Record_counts"$STARTDATE.csv ... (2 Replies)
Discussion started by: Shanks
2 Replies

6. UNIX for Advanced & Expert Users

File Delimiter

Hi All, I woul like to know with out opening a file in unix ,how we can find out what is the delemeter in that file... Thanks.. edit by bakunin: changed thread title to "delimiter" so it can be found. (4 Replies)
Discussion started by: raju4u
4 Replies

7. Shell Programming and Scripting

Help with changing text file layout

Hi there, I am with this one column input text file to change layout, please help. Thanks. I have awk, sed. $ cat input Median 1.0 2.3 3.0 Median 35.0 26.3 45.7 10.1 63.1 Median 1.2 2.3 (8 Replies)
Discussion started by: cwzkevin
8 Replies

8. Shell Programming and Scripting

Shell script to put delimiter for a no delimiter variable length text file

Hi, I have a No Delimiter variable length text file with following schema - Column Name Data length Firstname 5 Lastname 5 age 3 phoneno1 10 phoneno2 10 phoneno3 10 sample data - ... (16 Replies)
Discussion started by: Gaurav Martha
16 Replies

9. UNIX for Dummies Questions & Answers

Getting the folder name and file name after delimiter

Hi, I have a input /dev/cm/test1.txt /qa/tm/hmkr/cc/test2.txt and I need an out like below foldername, filename /dev/cm/,test1.txt /qa/tm/hmkr/cc/,test2.txt I tried with awk $NF, but I'm getting the filenames and not folder names. Please let me know how to achive the above... (5 Replies)
Discussion started by: somu_june
5 Replies

10. Shell Programming and Scripting

Perl Code to change file delimiter (passed as argument) to bar delimiter

Hi, Extremely new to Perl scripting, but need a quick fix without using TEXT::CSV I need to read in a file, pass any delimiter as an argument, and convert it to bar delimited on the output. In addition, enclose fields within double quotes in case of any embedded delimiters. Any help would... (2 Replies)
Discussion started by: JPB1977
2 Replies
OPAL_CRS(7)							     Open MPI							       OPAL_CRS(7)

NAME
OPAL_CRS - Open PAL MCA Checkpoint/Restart Service (CRS): Overview of Open PAL's CRS framework, and selected modules. Open MPI 1.4.5. DESCRIPTION
Open PAL can involuntarily checkpoint and restart sequential programs. Doing so requires that Open PAL was compiled with thread support and that the back-end checkpointing systems are available at run-time. Phases of Checkpoint / Restart Open PAL defines three phases for checkpoint / restart support in a procress: Checkpoint When the checkpoint request arrives, the procress is notified of the request before the checkpoint is taken. Continue After a checkpoint has successfully completed, the same process as the checkpoint is notified of its successful continuation of execu- tion. Restart After a checkpoint has successfully completed, a new / restarted process is notified of its successful restart. The Continue and Restart phases are identical except for the process in which they are invoked. The Continue phase is invoked in the same process as the Checkpoint phase was invoked. The Restart phase is only invoked in newly restarted processes. GENERAL PROCESS REQUIREMENTS
In order for a process to use the Open PAL CRS components it must adhear to a few programmatic requirements. First, the program must call OPAL_INIT early in its execution. This should only be called once, and it is not possible to checkpoint the process without it first having called this function. The program must call OPAL_FINALIZE before termination. This does a significant amount of cleanup. If it is not called, then it is very likely that remnants are left in the filesystem. To checkpoint and restart a process you must use the Open PAL tools to do so. Using the backend checkpointer's checkpoint and restart tools will lead to undefined behavior. To checkpoint a process use opal_checkpoint (opal_checkpoint(1)). To restart a process use opal_restart (opal_restart(1)). AVAILABLE COMPONENTS
Open PAL ships with two CRS components: self and blcr. The following MCA parameters apply to all components: crs_base_verbose Set the verbosity level for all components. Default is 0, or silent except on error. crs_base_snapshot_dir The directory to store the checkpoint snapshots. Default is /tmp. self CRS Component The self component invokes user-defined functions to save and restore checkpoints. It is simply a mechanism for user-defined functions to be invoked at Open PAL's Checkpoint, Continue, and Restart phases. Hence, the only data that is saved during the checkpoint is what is written in the user's checkpoint function. No libary state is saved at all. As such, the model for the self component is slightly differnt than for other components. Specifically, the Restart function is not invoked in the same process image of the process that was checkpointed. The Restart phase is invoked during OPAL_INIT of the new instance of the applicaiton (i.e., it starts over from main()). The self component has the following MCA parameters: crs_self_prefix Speficy a string prefix for the name of the checkpoint, continue, and restart functions that Open PAL will invoke during the respective stages. That is, by specifying "-mca crs_self_prefix foo" means that Open PAL expects to find three functions at run-time: int foo_checkpoint() int foo_continue() int foo_restart() By default, the prefix is set to "opal_crs_self_user". crs_self_priority Set the self components default priority crs_self_verbose Set the verbosity level. Default is 0, or silent except on error. crs_self_do_restart This is mostly internally used. A general user should never need to set this value. This is set to non-0 when a the new process should invoke the restart callback in OPAL_INIT. Default is 0, or normal execution. blcr CRS Component The Berkeley Lab Checkpoint/Restart (BLCR) single-process checkpoint is a software system developed at Lawrence Berkeley National Labora- tory. See the project website for more details: http://ftg.lbl.gov/CheckpointRestart/CheckpointRestart.shtml The blcr component has the following MCA parameters: crs_blcr_priority Set the blcr components default priority. crs_blcr_verbose Set the verbosity level. Default is 0, or silent except on error. none CRS Component The none component simply selects no CRS component. All of the CRS function calls return immediately with OPAL_SUCCESS. This component is the last component to be selected by default. This means that if another component is available, and the none component was not explicity requested then OPAL will attempt to activate all of the available components before falling back to this component. SEE ALSO
opal_checkpoint(1), opal_restart(1) 1.4.5 Feb 10, 2012 OPAL_CRS(7)
All times are GMT -4. The time now is 07:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy