Sponsored Content
Top Forums Shell Programming and Scripting Need separate vi files in shell Post 302960316 by buzzme on Friday 13th of November 2015 12:38:09 PM
Old 11-13-2015
Hi Cudic,

I did't get you could you pleae elaborate your solution.

do i need to include above awk you provided in Yoda's script?

---------- Post updated at 12:38 PM ---------- Previous update was at 12:33 PM ----------

Hello Rudic,

I tried below it did't worked
Code:
awk '!/^ '
        NF && !/^ / {
                ofile = $1
                next
        }
        NF && /^ / {
                print $1 >> ofile
                close(ofile)
        }
'   / {OFN=$1; next} {print > OFN}' test1

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Break a file into separate files

Hello I am facing a scenario where I have a file with XML content and I am running shell script over it. But the problem is the XML is getting updated with new services. In the below scenario, my script takes values from the xml file from one service name say ABCD. Since there are multiple, it is... (8 Replies)
Discussion started by: chiru_h
8 Replies

2. Shell Programming and Scripting

Separate String Shell Script

Hi guys, I am a beginner in shell script.. How can I separate a string coming from a parameter in spaces ? Ex: input: test.sh abcd output: a b c d Thanks Dusse (15 Replies)
Discussion started by: dusse
15 Replies

3. Shell Programming and Scripting

Separating Pattern Into Separate Files

I am trying to separate a specific pattern match into separate files. Sometimes there is only one pattern match, but other times there could be multiple (up to 6 or 8). Pattern is as follows - its starts with NYZ or VTZ and ends with $$. Again looking to get those blocks of data from one big... (17 Replies)
Discussion started by: Double-E
17 Replies

4. Shell Programming and Scripting

Need help with shell, trying to append or separate values in a string

Ok. I for the life of me cant figure out how to do this. I need Help. So here is what I'm trying to do. I have a block of text. They are FIPS codes for counties. Below is the block. There are probably a few ways to do this. The first line starting with ARC021....... this line is a list of... (2 Replies)
Discussion started by: chagan02
2 Replies

5. Shell Programming and Scripting

Comparing columns in two separate files

Hey all, I have a file structure that looks something like this: file1 306708278 88954535 234167885 file2 2012-03-27T12:32:56+00:00 137 Orchotorena 184616310003601409 306708278 es 40.4777947 Majadahonda -3.6416896333333333 0 false atlante83 "<a href=""http://tapbots.com/tweetbot""... (8 Replies)
Discussion started by: dgaff
8 Replies

6. Shell Programming and Scripting

Using bash to separate files files based on parts of a filename

Hey guys, Sorry for the basic question but I have a lot of files that I want to separate into groups based on filenames which I can then cat together. Eg I have: (a_b_c.txt) WB34_2_SLA8.txt WB34_1_SLA8.txt WB34_1_DB10.txt WB34_2_DB10.txt WB34_1_SLA8.txt WB34_2_SLA8.txt 77_1_SLA8.txt... (1 Reply)
Discussion started by: Breentax
1 Replies

7. Web Development

Two separate domains - and files

Hi, I've been asked to 'troubleshoot' a webserver where two different TLDs are being served. Or to be more accurate, 'domain.com' and 'domain.fr'. So we have /var/www/domain.com /var/www/domain.fr And then for some reason, the httpd.conf file points to two different configuration files.... (1 Reply)
Discussion started by: davidm123SED
1 Replies

8. UNIX for Dummies Questions & Answers

Intersect of two columns in two separate files

Hi, I have a file like this: abc def ghi jkl mno My second file is like this (tab delimited): adsad sdfsdf dfdf wads abc dfdsf sdsf jkl sfsdf dsfds sdfd reor zxczd dsf sff Now, I want the code to report the lines (from file2) which have common strings in column 2 with the first... (4 Replies)
Discussion started by: a_bahreini
4 Replies

9. Shell Programming and Scripting

Output in separate files

Hi all, i have the bash script for remote conection, for hosts in $(cat /list); do ssh user1@$hosts "hostname"; done execute hostname command by all hosts and show standar ouput, how i can send to file by each host in lists, so e.g. $cat list 10.0.0.1 10.0.0.2... (1 Reply)
Discussion started by: aav1307
1 Replies

10. Shell Programming and Scripting

Tar with variable date in separate shell

Hi, I am trying to Zip a folder inside a shell script like below. It successfully taring but it only returns Null inside the variables. Searched a lot but no clue to finding the root cause. testno=1; date=20171128; DIR=/root/ sh -c 'cd $DIR; tar cvf "AWS.${testno.${date}.tar" "./AWS"' ... (5 Replies)
Discussion started by: pradyumnajpn10
5 Replies
SHTOOL-SCPP.TMP(1)					      GNU Portable Shell Tool						SHTOOL-SCPP.TMP(1)

NAME
shtool-scpp - GNU shtool C source file pre-processor SYNOPSIS
shtool scpp [-v|--verbose] [-p|--preserve] [-f|--filter filter] [-o|--output ofile] [-t|--template tfile] [-M|--mark mark] [-D|--define dname] [-C|--class cname] file [file ...] DESCRIPTION
This command is an additional ANSI C source file pre-processor for sharing cpp(1) code segments, internal variables and internal functions. The intention for this comes from writing libraries in ANSI C. Here a common shared internal header file is usually used for sharing information between the library source files. The operation is to parse special constructs in files, generate a few things out of these constructs and insert them at position mark in tfile by writing the output to ofile. Additionally the files are never touched or modified. Instead the constructs are removed later by the cpp(1) phase of the build process. The only prerequisite is that every file has a ``"#include ""ofile"""'' at the top. This command provides the following features: First it avoids namespace pollution and reduces prototyping efforts for internal symbols by recognizing functions and variables which are defined with the storage class identifier ``cname''. For instance if cname is ``intern'', a function ``"intern void *foobar(int quux)"'' in one of the files is translated into both a ``"#define foobar __foobar"'' and a ``"extern void *foobar(int quux);"'' in ofile. Additionally a global ``"#define" cname "/**/"'' is also created in ofile to let the compiler silently ignore this additional storage class identifier. Second, the library source files usually want to share "typedef"s, "#define"s, etc. over the source file boundaries. To achieve this one can either place this stuff manually into tfile or use the second feature of scpp: All code in files encapsulated with ``"#if "dname ... "#endif"'' is automatically copied to ofile. Additionally a global ``"#define" dname 0'' is also created in ofile to let the compiler silently skip this parts (because it was already found in the header). OPTIONS
The following command line options are available. -v, --verbose Display some processing information. -p, --preserve Preserves ofile independent of the generated ``#line'' lines. This is useful for Makefiles if the real contents of ofile will not change, just line numbers. Default is to overwrite. -f, --filter filter Apply one or more pre-processing sed(1) filter commands (usually of type ``"s/.../.../"'') to each input file before their input is parsed. This option can occur multiple times. -o, --output ofile Output file name. Default is "lib.h". -t, --template tfile Template file name. Default is "lib.h.in". -M, --mark mark Mark to be replaced by generated constructs. Default is "%%MARK%%". -D, --define dname FIXME. Default is "cpp". -C, --class cname FIXME. Default is "intern". EXAMPLE
# Makefile SRCS=foo_bar.c foo_quux.c foo_p.h: foo_p.h.in shtool scpp -o foo_p.h -t foo_p.h.in -M %%MARK%% -D cpp -C intern $(SRCS) /* foo_p.h.in */ #ifndef FOO_P_H #define FOO_P_H %%MARK%% #endif /* FOO_P_H */ /* foo_bar.c */ #include "foo_p.h" #if cpp #define OURS_INIT 4711 #endif intern int ours; static int myone = 0815; intern int bar(void) { ours += myone; } /* foo_quux.c */ #include "foo_p.h" int main(int argc, char *argv[]) { int i; ours = OURS_INIT for (i = 0; i < 10; i++) { bar(); printf("ours now %d ", ours); } return 0; } HISTORY
The GNU shtool scpp command was originally written by Ralf S. Engelschall <rse@engelschall.com> in 1999 for GNU shtool. Its was prompted by the need to have a pre-processing facility in the GNU pth project. SEE ALSO
shtool(1), cpp(1). 18-Jul-2008 shtool 2.0.8 SHTOOL-SCPP.TMP(1)
All times are GMT -4. The time now is 11:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy