Sponsored Content
Top Forums Shell Programming and Scripting Copying Information from One File to Another File in Shell Post 302538649 by Shell_Life on Wednesday 13th of July 2011 04:27:37 PM
Old 07-13-2011
See if this works for you:
Code:
#!/usr/bin/ksh
mPTag=""
egrep '^Ac-' mFile2 > mFile2.tag
egrep '^Ac-' mFile3 > mFile3.tag
sort mFile1 mFile2.tag mFile3.tag | while read mTag mFld1 mFld2 mFld3 mFld4 mRest; do
  if [[ "${mTag}" != "${mPTag}" ]]; then
    if [[ "${mPTag}" != "" ]]; then
      mOutLine=${mPTag}' '${mPFld1}' '${mPFld2}' '${mPFld3}' '${mValue2}' '${mPFld4}' '${mValue1}' '${mPRest}
      echo ${mOutLine}
    fi
    mValue1=0
    mValue2=0
  fi
  if [[ "${mFld2}" = "" ]]; then
    mValue1=${mFld1}
  else
    if [[ "${mFld3}" = "" ]]; then
      mValue2=${mFld2}
    else
      mPFld1=${mFld1}
      mPFld2=${mFld2}
      mPFld3=${mFld3}
      mPFld4=${mFld4}
      mPRest=${mRest}
    fi
  fi
  mPTag=${mTag}
done
if [[ "${mPTag}" != "" ]]; then
  mOutLine=${mPTag}' '${mPFld1}' '${mPFld2}' '${mPFld3}' '${mValue2}' '${mPFld4}' '${mValue1}' '${mPRest}
  echo ${mOutLine}
fi

 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

Strange difference in file size when copying LARGE file..

Hi, Im trying to take a database backup. one of the files is 26 GB. I am using cp -pr to create a backup copy of the database. after the copying is complete, if i do du -hrs on the folders i saw a difference of 2GB. The weird fact is that the BACKUP folder was 2 GB more than the original one! ... (1 Reply)
Discussion started by: 0ktalmagik
1 Replies

2. Shell Programming and Scripting

sed command for copying the contents of other file replacing it another file on specifc pattern

We have 2 file XML files - FILE1.XML and FILE2.xml - we need copy the contents of FILE1.XML and replace in FILE2.xml pattern "<assignedAttributeList></assignedAttributeList>" FILE1.XML 1. <itemList> 2. <item type="Manufactured"> 3. <resourceCode>431048</resourceCode> 4. ... (0 Replies)
Discussion started by: balrajg
0 Replies

3. UNIX for Dummies Questions & Answers

Help with searching for a file in a directory and copying the contents of that file in a new file

Hi guys, I am a newbie here :wall: I need a script that can search for a file in a directory and copy the contents of that file in a new file. Please help me. :confused: Thanks in advance~ (6 Replies)
Discussion started by: zel2zel
6 Replies

4. Shell Programming and Scripting

shell script to sort information in one file

Hi to all, anyway to create shell script to sort informations from one file and create new file with the sorted values? from file 30days.out -bash-3.00# more 30days.out user/str4@kl.com/INBOX user/tg1@johor.com/INBOX user/tg2@kedah.com/INBOX user/tg3@titangroup.com/INBOX... (3 Replies)
Discussion started by: Mr_47
3 Replies

5. Shell Programming and Scripting

Create shell script to extract unique information from one file to a new file.

Hi to all, I got this content/pattern from file http.log.20110808.gz mail1 httpd: Account Notice: close igchung@abc.com 2011/8/7 7:37:36 0:00:03 0 0 1 mail1 httpd: Account Information: login sastria9@abc.com proxy sid=gFp4DLm5HnU mail1 httpd: Account Notice: close sastria9@abc.com... (16 Replies)
Discussion started by: Mr_47
16 Replies

6. Shell Programming and Scripting

copying file information using awk & grep

Hi, TASK 1: I have been using this code to print the information of files kept at "/castor/cern.ch/user/s/sudha/forPooja" in some text file name FILE.txt. rfdir /castor/cern.ch/user/s/sudha/forPooja | grep data | awk '{print "rfio:///castor/cern.ch/user/s/sudha/forPooja/"$9}' > FILE.txt ... (6 Replies)
Discussion started by: nrjrasaxena
6 Replies

7. Shell Programming and Scripting

Shell : copying from one file to another file

vat.log -------- null null statistics null null null Storage Response Time disk space1 disk space2 I have a log as mentioned above in which I need to copy only the below content to another file using shell scripting. In between null statistics and final null it also includes... (1 Reply)
Discussion started by: giridhar276
1 Replies

8. Shell Programming and Scripting

Shell :copying the content from one file to another

I have a log containing the below lines. file1.log ----------- module: module1 module10 module2 module002 module9 moduleRT100.2.1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... (1 Reply)
Discussion started by: giridhar276
1 Replies

9. Shell Programming and Scripting

Copying a string from a file using shell script

Hello everyone I am completely new to shell scripting in linux. I wan to write a script to search for a certain string from a .txt file and copy the string which apears just after tat searched string. Eg: in a file- try.txt , we have a line saying: "roses are red, so what do i do" I... (4 Replies)
Discussion started by: Kishore920
4 Replies

10. Shell Programming and Scripting

Shell Script for copying text file to Excel Sheet

Hi, I want to write a program to copy a log file to Excel sheet. Excel sheet has four columns MethodName , Code , Description, Details and Time. I want to pick these info from text file and put it in excel sheet. here is how the text file looks - 04.17.2014 08:06:12,697... (1 Reply)
Discussion started by: hershey
1 Replies
CREATEPYMB(1)						      General Commands Manual						     CREATEPYMB(1)

NAME
createPYMB, readPYBase, readPYMB, mb2org, scel2org - fcitx Pinyin related tools SYNOPSIS
createPYMB <PinyinFile> <PhraseFile> readPYBase [-b <PinyinMBFile>] [-h] readPYMB [-f <PhraseMBFile>] [-s] [-h] mb2org [-b <PinyinMBFile>] [-f <PhraseMBFile>] [-s] [-h] scel2org [-o <Phrase File>] [-h] DESCRIPTION
-b <PinyinMBFile> If not specified, it will read system default pybase.mb. -f <PhraseMBFile> If not specified, it will read user default PhraseMBFile, which is ~/.config/fcitx/pyusrphrase.mb. -s If specified, it will read PhraseMBFile as system format, otherwise will read it as user format. -h display help and exit Pinyin File Pinyin File is a file with pinyin and one character per line, separated with space. One available file is in the source of fcitx, named gbkpy.org. Phrase File Phrase File is a file with full pinyin separated with ' and the corresponding phrase. The default phrase file of fcitx can be down- loaded at http://fcitx.googlecode.com/files/pinyin.tar.gz. Pinyin MB File Pinyin MB File is the binary format of Pinyin File. Phrase MB File Phrase MB File is the binary format of Pinyin File, user's history phrase mb file is ~/.config/fcitx/pyuserphrase.mb. There is two different format, one is system format which can only generated by createPYMB , and other is user format which can only generated while input with fcitx Pinyin IM. Output of createPYMB will be pybase.mb, which is Pinyin MB File, and pyphrase.mb, which is Phrase MB File. Output of mb2org, readPYBase and readPYMB will be stdout. readPYBase and readPYMB are designed to output more debug message of Pinyin MB File and Phrase MB File. mb2org will output in the format of Phrase File. scel2org is used for transform Sogou Scel File to Phrase File of fcitx. Output of scel2org will be stdout if -o is not used. SEE ALSO
Please see the homepage at http://www.fcitx.org/ and http://fcitx.googlecode.com/ 2010-12-16 CREATEPYMB(1)
All times are GMT -4. The time now is 07:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy