Sponsored Content
Full Discussion: Problem to read archive
Top Forums Shell Programming and Scripting Problem to read archive Post 302367909 by Scrutinizer on Tuesday 3rd of November 2009 07:01:35 PM
Old 11-03-2009
One problem with your script, is that it should be bin, not Bin. Also you have to use double quotes around $registro to maintain appropriate spacing.
Code:
#!/bin/ksh
dir_work=/aplic/tmp
arquivo=file.txt
cd ${dir_work}
cat $arquivo | while read registro
do
   campo=`echo "$registro" | cut -c38-39`
   echo $registro >>${campo}_${arquivo} 
done

If you want to retain the original spacing of the input file in the output files you'd also have to use double quotes:
Code:
echo "$registro" >>${campo}_${arquivo}

You can easily check what your script is doing by temporarily using
Code:
#!/bin/ksh -x

An alternative way to do it would be:
Code:
#!/bin/ksh
dir_work=/aplic/tmp
arquivo=file.txt
cd ${dir_work}
while read registro; do
   campo=${registro:37:2}
   echo $registro >>${campo}_${arquivo}
done<$arquivo

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read from file then purge or archive.

Hi All, I have a root directory /tmp and I want to purge files or archive files in its subsequent subfolders.I listed the path of files I want to purge(archive) and the #of days. (purge) DAYS PATH 7 /tmp/arsenal/* 5 /tmp/chelsea/* (archive? the same as above but different folders... (15 Replies)
Discussion started by: kayarsenal
15 Replies

2. Shell Programming and Scripting

read list of filenames from text file, archive, and remove

I posted a week ago regarding this scripting question, but I need to revisit and have a few more questions answered.. User cfajohnson was extremely helpful with the archive script, but clarification on my part is needed to help steer the answer in a direction that works in this particular... (5 Replies)
Discussion started by: fxvisions
5 Replies

3. Solaris

problem in creating flash archive

Dear all I am in a problem. I have created a master server on which I have install a Solaris 10 OS as well as Oracle 10g with some additional solaris packages. Now I want to create a flash archive of this server and install that flash archive on another server, so that the new server will have... (6 Replies)
Discussion started by: girish.batra
6 Replies

4. Shell Programming and Scripting

Read specific file from a zip archive without extracting

Hi All, I would like to extract specific file from a zip archive. I have a zip archive "sample.zip". sample.zip contains few text files and images... text1.txt, text2.txt, pic.jpg etc... I need to read specific file "text2.txt" from "sample.zip" WITHOUT EXTRACTING the zip file. ... (4 Replies)
Discussion started by: sridharg
4 Replies

5. Programming

read file from tar.gz archive

I want to write a c-program which reads a textfile from a tar.gz archive. How can I do it? (9 Replies)
Discussion started by: krylin
9 Replies

6. Shell Programming and Scripting

Archive::Tar problem

Hello, I have a problem using Archive::Tar. it seem very trivial but i cannot get it work. First I have a list of files I grab from a directory. Then I create a tar archive and write the files into the archive. everything works great, except that I cannot properly extract the files. What... (0 Replies)
Discussion started by: amcrisan
0 Replies

7. Shell Programming and Scripting

Extracting from archive | compressing to new archive

Hi there, I have one huge archive (it's a system image). I need sometime to create smaller archives with only one or two file from my big archive. So I'm looking for a command that extracts files from an archive and pipe them to another one. I tried the following : tar -xzOf oldarchive.tgz... (5 Replies)
Discussion started by: chebarbudo
5 Replies

8. Solaris

Boot-archive Problem

I disabled the boot-archive service by using #svcadm disable svc:/system/boot-archive:default then i rebooted my system but i am unable to boot. It throws the following errors CONSOLE LOGIN SERVICE(S) CANNOT RUN then it automatically asked me for the maintenance mode passwd. i logged... (3 Replies)
Discussion started by: dinu
3 Replies

9. Shell Programming and Scripting

Script to archive logs and sftp to another archive server

Requirement: Under fuse application we have placeholders called containers; Every container has their logs under: <container1>/data/log/fuse.log <container1>/data/log/fuse.log.1 <container1>/data/log/fuse.log.XX <container2>/data/log/fuse.log... (6 Replies)
Discussion started by: Arjun Goswami
6 Replies
set_color(1)							       fish							      set_color(1)

NAME
set_color - set_color - set the terminal color set_color - set the terminal color Synopsis set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR] Description Change the foreground and/or background color of the terminal. COLOR is one of black, red, green, brown, yellow, blue, magenta, purple, cyan, white and normal. o -b, --background Set the background color o -c, --print-colors Prints a list of all valid color names o -h, --help Display help message and exit o -o, --bold Set bold or extra bright mode o -u, --underline Set underlined mode o -v, --version Display version and exit Calling set_color normal will set the terminal color to whatever is the default color of the terminal. Some terminals use the --bold escape sequence to switch to a brighter color set. On such terminals, set_color white will result in a grey font color, while set_color --bold white will result in a white font color. Not all terminal emulators support all these features. This is not a bug in set_color but a missing feature in the terminal emulator. set_color uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and may lack color information for terminals that support it. Download and install the latest version of ncurses and recompile fish against it in order to fix this issue. Version 1.23.1 Sun Jan 8 2012 set_color(1)
All times are GMT -4. The time now is 07:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy