Sponsored Content
Top Forums Shell Programming and Scripting Removing last character of string Post 302365476 by danmero on Tuesday 27th of October 2009 07:21:52 AM
Old 10-27-2009
awk can solve your problem Smilie
Code:
awk -F, '{for(i=0;++i<=NF;)if($i~/_DL/){x=(x)?x FS $i:$i}}END{print x}' file

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Removing the ^M character in VI

Hello, I am attempting to remove all the ^M characters in a file in VI. The command I am using is :1,$s/^V^M//g but it doesn't work, saying 'substitute pattern match failed'. Any ideas why? Jules (2 Replies)
Discussion started by: julesinbath
2 Replies

2. UNIX for Advanced & Expert Users

Removing first character in a string

While writing a shell script i happen to store some value in a string. Lets say the value is 59788. Now in this script i want to get the value 9788 removing the first charater 5. The original string length usually remains constant. Is there a single line command to do this or any simple way to... (4 Replies)
Discussion started by: npn
4 Replies

3. Shell Programming and Scripting

Removing character ' from a variable

Hello there, I have a variable in the form of '/example/file.txt' . I want to remove the ' characters from the beginning and the end so that the my new variable becomes /example/file.txt . How can I do it in a script? I know this is a fairly easy question, but i wasn't able to implement it. (3 Replies)
Discussion started by: sertansenturk
3 Replies

4. Shell Programming and Scripting

Korn: How to loop through a string character by character

If I have a string defined as: MyString=abcde echo $MyString How can I loop through it character by character? I haven't been able to find a way to index the string so that I loop through it. shew01 (10 Replies)
Discussion started by: shew01
10 Replies

5. Shell Programming and Scripting

Need some help removing a character from name

I have a file like this: DDD_ABCDE2AB2_1104081408.104480 I need to remove the 1 after the . in the file name so that it reads: DDD_ABCDE2AB2_1104081408.04480 Having some difficulty getting the command to work. I tried using cut -d 26 but that just doesn't work. (3 Replies)
Discussion started by: bbbngowc
3 Replies

6. UNIX for Dummies Questions & Answers

Removing a character

I need to remove square brackets from output of script. Output is: and I need to remove the square brackets so I am lett with 121 Is sed the only means to do this and if so what are the options? ...ok so far I have managed to get rid of ] by using /usr/bin/sed 's/]//' but that... (5 Replies)
Discussion started by: rob171171
5 Replies

7. UNIX for Dummies Questions & Answers

Need help removing last character of every line if certain character

I need help removing the last character of every line if it is a certain character. For example I need to get rid of a % character if it is in the last position. Input: aaa% %bbb ccc d%dd% Output should be: aaa %bbb ccc d%dd I tried this but it gets rid of all of the % characters.... (5 Replies)
Discussion started by: raptor25
5 Replies

8. Shell Programming and Scripting

removing last character

Hi, I have a file that has data something like below: A B C D ..... ...... .....and so on I am trying to bring it in one line with comma delimited something like below : A,B,C,D I tried the something below in the code section: cat File.txt | tr '\n' ',' (1 Reply)
Discussion started by: rkumar28
1 Replies

9. UNIX for Dummies Questions & Answers

[Solved] Removing an 8 character string

Edit: Figured it out. Close the thread please. Solution: \{8}\] edit by bakunin: no need to close the thread, but i changed the title to SOLVED. Thanks for writing a follow-up. (0 Replies)
Discussion started by: unknownn
0 Replies

10. Shell Programming and Scripting

sed searches a character string for a specified delimiter character, and returns a leading or traili

Hi, Anyone can help using SED searches a character string for a specified delimiter character, and returns a leading or trailing space/blank. Text file : "1"|"ExternalClassDEA519CF5"|"Art1" "2"|"ExternalClass563EA516C"|"Art3" "3"|"ExternalClass305ED16B8"|"Art9" ... ... ... (2 Replies)
Discussion started by: fspalero
2 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 07:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy