Search Results

Search: Posts Made By: Jairaj
2,720
Posted By Don Cragun
Making lots of wild assumptions about what...
Making lots of wild assumptions about what operating system (and, therefore what type of shell is installed as sh, one might try something like the following:
#!/bin/sh
IAm=${0##*/}

if [ $# -lt...
1,496
Posted By bakunin
If i may try? sed...
If i may try?

sed 's/ABC\|XYZ\|KMN/\n&/g;s/^\n//' file

This sed-program consists of two statements which are applied one after the other to every line:

s/ABC\|XYZ\|KMN/\n&/g
s/^\n//

Let...
1,496
Posted By RavinderSingh13
Hello Jairaj, In awk, could you please try...
Hello Jairaj,

In awk, could you please try following.

awk '{gsub("ABC|XYZ|MNO|KMN",ORS"&");sub(/^\n/,"")} 1' Input_file


Thanks,
R. Singh
2,384
Posted By nezabudka
Try sed -r 's/\BABC|\BXYZ|\BKMN/\n&/g' file ...
Try
sed -r 's/\BABC|\BXYZ|\BKMN/\n&/g' file
or
sed -r 's/ABC|XYZ|KMN/\n&/g;s/\n//' file
1,904
Posted By danmero
# awk -F'[ |]' '{for(i=0;++i<=NF;){if($i){printf...
# awk -F'[ |]' '{for(i=0;++i<=NF;){if($i){printf $i ((i==NF)?ORS:($i~"the|ke")?OFS:"|")}}}' file
1|2|3|test|james|ke the one|value
1|2|3|test|the value|comp
1|2|3|test|james|value...
1,999
Posted By itkamaraj
$2=$2"|"$NF; # replacing the $2 value with $2 +...
$2=$2"|"$NF; # replacing the $2 value with $2 + "|" + $NF (last column value)
For loop # to print all the values except last value ( condition is i < NF)
1,999
Posted By Chubler_XL
How about this: echo...
How about this:

echo "a|b|c|d|test|123|same" | awk 'BEGIN {FS=OFS="|"} { $3=$NF;NF--;print }'
1,681
Posted By guruprasadpr
$ cat file xyz123abc509kai330 aca203 ...
$ cat file
xyz123abc509kai330
aca203
ald390afa000als303

Output:
$ fold -w6 file
xyz123
abc509
kai330
aca203
ald390
afa000
als303

Guru.
Showing results 1 to 8 of 8

 
All times are GMT -4. The time now is 09:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy