Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Print strings from a particular position in each line Post 303041194 by zxmaus on Sunday 17th of November 2019 11:27:36 PM
Old 11-18-2019
there are probably a million ways to do it more elegantly but I would probably just try this
Code:
ls -ali | rev | cut -d' ' -f 1 | cut -c 1-7 | cut -c 5-99 | rev

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to insert strings at certain position

Hi, I need to insert strings "0000 00" at the each line within the file. The postion is 37 to 42. ex. name1 name2 0000 00 nam name 0000 00 The "0000 00" in two lines should be lined up. I don't know why it's not lined up when I posted it. Can anyone help? (14 Replies)
Discussion started by: whatisthis
14 Replies

2. Shell Programming and Scripting

Finding character mismatch position in two strings

Hello, I would like to find an efficient way to compare a pair of strings that differ at one position, and return the difference and position. For example: String1 123456789 String2 123454789 returning something - position 6, 6/4 Thanks in advance, Mike (5 Replies)
Discussion started by: etherite
5 Replies

3. Shell Programming and Scripting

how to find a position and print some string in the next and same position

I need a script for... how to find a position of column data and print some string in the next line and same position position should find based on *HEADER8* in text for ex: ord123 abs 123 987HEADER89 test234 ord124 abc 124 987HEADER88 test235 ... (1 Reply)
Discussion started by: naveenkcl
1 Replies

4. Shell Programming and Scripting

Search for multiple strings in specific position

Hi, I need to search for some strings in specific positions in a file. If the strings: "foo1", "foo2" or "foo3" is on position 266 or position 288 in a file i want the whole line printed. Any idea how to do it? (5 Replies)
Discussion started by: HugoH
5 Replies

5. Shell Programming and Scripting

Search in specific position and print the whole line

I have two files abc.dat and sant.dat (Big file 60k rows) for every line's 1,4 of abc.dat need to seach if this is present on 28,4 of sant.dat every line. if its present the output needs to go to bde.dat Example: contents abc.dat aaaa bbbb cccc dddd contents sant.dat this is... (4 Replies)
Discussion started by: ssantoshss
4 Replies

6. Shell Programming and Scripting

grep a string and print strings on that line

i have a file like below ABS 12234 A C 12G CFY 23865 A C 34D i want to grep "A C" then print ABS 12G 12234 CFY 34D 23865 Thanks! (4 Replies)
Discussion started by: kingpeejay
4 Replies

7. UNIX for Dummies Questions & Answers

Help with finding matching position on strings

I have a DNA file like below and I am able to write a short program which finds/not an input motif, but I dont understand how I can include in the code to report which position the motif was found. Example I want to find the first or all "GAT" motifs and want the program to report which position... (12 Replies)
Discussion started by: pawannoel
12 Replies

8. Shell Programming and Scripting

How to print few strings in a line?

I have one script which gave final output as the below statment. Successfully added Nomination Petition Manifest to the Content Manager. Now i want a sed statement which will search for this statement in any given file and print only Nomination Petition Manifest. I don't want to hardcore... (13 Replies)
Discussion started by: Vikram_Tanwar12
13 Replies

9. Shell Programming and Scripting

Print the complete line based on position as input

Hi , I have a text file like below abcd2223232321212121324343 asdsfffhfgfgfhgfhghghghghghgh dfdfdfgfghfgfgfgfgfgghghghghgh dfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdf 1234567890sasasasfdfbffghffhf abcd222323232121212abcdsds in the above file i need to grep and print the lines if 14th to 18th... (4 Replies)
Discussion started by: aravindj80
4 Replies

10. Shell Programming and Scripting

Need command or script to print all lines from 2nd position to last but one position

hi guys, i want command or script to display the content of file from 2nd position to last but one position of a file abcdefghdasdasdsd 123,345,678,345,323 434,656,656,656,656 678,878,878,989,545 4565656667,65656 i want to display the same above file without first and... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies
exstr(1)							   User Commands							  exstr(1)

NAME
exstr - extract strings from source files SYNOPSIS
exstr filename... exstr -e filename... exstr -r [-d] filename... DESCRIPTION
The exstr utility is used to extract strings from C-language source files and replace them by calls to the message retrieval function (see gettxt(3C)). This utility will extract all character strings surrounded by double quotes, not just strings used as arguments to the printf command or the printf routine. In the first form, exstr finds all strings in the source files and writes them on the standard output. Each string is preceded by the source file name and a colon (:). The first step is to use exstr -e to extract a list of strings and save it in a file. Next, examine this list and determine which strings can be translated and subsequently retrieved by the message retrieval function. Then, modify this file by deleting lines that can't be translated and, for lines that can be translated, by adding the message file names and the message numbers as the fourth (msgfile) and fifth (msgnum) entries on a line. The message files named must have been created by mkmsgs(1) and exist in /usr/lib/locale/locale/LC_MES- SAGES . (The directory locale corresponds to the language in which the text strings are written; see setlocale(3C)). The message numbers used must correspond to the sequence numbers of strings in the message files. Now use this modified file as input to exstr -r to produce a new version of the original C-language source file in which the strings have been replaced by calls to the message retrieval function gettxt(). The msgfile and msgnum fields are used to construct the first argument to gettxt(). The second argument to gettxt() is printed if the message retrieval fails at run-time. This argument is the null string, unless the -d option is used. This utility cannot replace strings in all instances. For example, a static initialized character string cannot be replaced by a function call. A second example is that a string could be in a form of an escape sequence which could not be translated. In order not to break existing code, the files created by invoking exstr -e must be examined and lines containing strings not replaceable by function calls must be deleted. In some cases the code may require modifications so that strings can be extracted and replaced by calls to the message retrieval function. OPTIONS
The following options are supported: -e Extract a list of strings from the named C-language source files, with positional information. This list is produced on standard output in the following format: file:line:position:msgfile:msgnum:string file the name of a C-language source file line line number in the file position character position in the line msgfile null msgnum null string the extracted text string Normally you would redirect this output into a file. Then you would edit this file to add the values you want to use for msgfile and msgnum: msgfile the file that contains the text strings that will replace string. A file with this name must be created and installed in the appropriate place by the mkmsgs(1) utility. msgnum the sequence number of the string in msgfile. The next step is to use exstr -r to replace strings in file. -r Replace strings in a C-language source file with function calls to the message retrieval function gettxt(). -d This option is used together with the -r option. If the message retrieval fails when gettxt() is invoked at run-time, then the extracted string is printed. You would use the capability provided by exstr on an application program that needs to run in an international environment and have messages print in more than one language. exstr replaces text strings with function calls that point at strings in a message data base. The data base used depends on the run-time value of the LC_MESSAGES environment variable (see environ(5)). EXAMPLES
Example 1: The following examples show uses of exstr Assume that the file example.c contains two strings: main() { printf("This is an example "); printf("Hello world! "); } The exstr utility, invoked with the argument example.c extracts strings from the named file and prints them on the standard output. example% exstr example.c produces the following output: example.c:This is an example example.c:Hello world! The exstr utility, invoked with the -e option and the argument example.c, and redirecting output to the file example.stringsout example% exstr -e example.c > example.stringsout produces the following output in the file example.stringsout example.c:3:8:::This is an example example.c:4:8:::Hello world! You must edit example.stringsout to add the values you want to use for the msgfile and msgnum fields before these strings can be replaced by calls to the retrieval function. If UX is the name of the message file, and the numbers 1 and 2 represent the sequence number of the strings in the file, here is what example.stringsout looks like after you add this information: example.c:3:8:UX:1:This is an example example.c:4:8:UX:2:Hello world! The exstr utility can now be invoked with the -r option to replace the strings in the source file by calls to the message retrieval func- tion gettxt(). example% exstr -r example.c <example.stringsout >intlexample.c produces the following output: extern char *gettxt(); main() { printf(gettxt("UX:1", "")); printf(gettxt("UX:2", "")); } The following example: example% exstr -rd example.c <example.stringsout >intlexample.c uses the extracted strings as a second argument to gettxt(): extern char *gettxt(); main() { printf(gettxt("UX:1", "This is an example ")); printf(gettxt("UX:2", "Hello world! ")); } FILES
/usr/lib/locale/locale/LC_MESSAGES/* files created by mkmsgs(1) ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWtoo | +-----------------------------+-----------------------------+ SEE ALSO
gettxt(1), mkmsgs(1), printf(1), srchtxt(1), gettxt(3C), printf(3C), setlocale(3C), attributes(5), environ(5) DIAGNOSTICS
The error messages produced by exstr are intended to be self-explanatory. They indicate errors in the command line or format errors encoun- tered within the input file. SunOS 5.10 5 Jul 1990 exstr(1)
All times are GMT -4. The time now is 11:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy