Search Results

Search: Posts Made By: sunnydanniel
14,314
Posted By Scott
$ echo $PWD /Users/scott/scripts $ echo...
$ echo $PWD
/Users/scott/scripts

$ echo ${PWD%/*}
/Users/scott
14,314
Posted By bartus11
dirname
dirname
1,235
Posted By Corona688
The only worry I'd have about modifying the same...
The only worry I'd have about modifying the same file repeatedly is that the table of contents must be changed, every time. It's not simply adding to the end. Mess up the table of contents and the...
1,235
Posted By Corona688
Depends what you mean by "zip file". If you...
Depends what you mean by "zip file".

If you mean zip file as in an honest-to-goodness, pkware-compatible, old-fashioned .zip file as created by the zip and unzip commands, then yes. Files in .zip...
7,100
Posted By alister
The while loop will abort at the first empty...
The while loop will abort at the first empty field because $i != "" evaluates to false. With the sample data provided and with the field separator you're using (any non-digit), the comparision is...
7,100
Posted By tukuyomi
Someone, tell me what's wrong with this code,...
Someone, tell me what's wrong with this code, please?
awk -F'[^0-9]' '{s="";i=0;while(++i<=NF&&$i!="")s=s$i"\t"}$0=s' file
7,100
Posted By alister
tr -cs '[:digit:]' '[\t*]'
tr -cs '[:digit:]' '[\t*]'
7,100
Posted By tukuyomi
~/unix.com$ awk -F'[^0-9]'...
~/unix.com$ awk -F'[^0-9]' '{s="";for(i=1;i<=NF;i++){if($i!="")s=s$i"\t"}print s}' file
7,100
Posted By balajesuri
perl -ne 'while(/(\d+)/g){print "$1\t"}'...
perl -ne 'while(/(\d+)/g){print "$1\t"}' inputfile
7,100
Posted By Skrynesaver
You probably don't want to use cut, it's fast but...
You probably don't want to use cut, it's fast but inflexible (to the best of my knowledge you cant have a variable delimiter). try the following approach:

perl -e 'print...
2,448
Posted By rangarasan
Hi, Try this, awk...
Hi,
Try this,

awk '/M0271857/{l=length($0);if(min==""){min=l;r=$0;}else{if(l<min){min=l;r=$0;}}}END{print r;}' file

Cheers,
Ranga:-)
2,448
Posted By Corona688
awk '/M0271857/ && ((!L) ||...
awk '/M0271857/ && ((!L) || (length(L)>length($0))) { L=$0 } END { print L }' datafile

Meaning:

/M0271857/ # for all lines where your string matches
&& ((!L) || (length(L)>length($0))) #...
18,522
Posted By chihung
If you are doing this within a loop, you may want...
If you are doing this within a loop, you may want to consider using the built-in feature of bash/ksh parameter expansion. This will save you 1 exec for every loop

v="abc/def/ghi/jkl/mn.txt"
echo...
18,522
Posted By bab@faa
Try using basename <full_path_to_file> $...
Try using basename <full_path_to_file>

$ basename /sndc002/app/appsndc/sndcappl/admin/sndc01.txt
sndc01.txt
18,522
Posted By joeyg
What about something like?
$ echo "abc/def/gh/joe.txt" | awk -F"/" '{print $NF}'
joe.txt
1,391
Posted By Corona688
Like shown, it's a textfile named radar.awk ...
Like shown, it's a textfile named radar.awk

It's not perl, it's awk.

You run it as shown, awk -f radar.awk filename

The data is printed to the screen, as shown.

awk -f radar.awk filename...
1,391
Posted By Corona688
That's a pretty ugly input file, unless it was...
That's a pretty ugly input file, unless it was originally tab-separated and ruined by copy-pasting it into a web postbox, but:

$ cat radar.awk

BEGIN {
OFS=","
# excel expects...
1,391
Posted By birei
Hi sunnydanniel, Put here the spreadsheet...
Hi sunnydanniel,

Put here the spreadsheet you want as output. It will be helpful for anyone who would like to help you.

Regards,
Birei
10,996
Posted By Corona688
The -F is necessary. () are special characters...
The -F is necessary. () are special characters to the shell and to grep. You must prevent the shell from expanding them with "", and grep from interpreting them with -F.

My version of egrep...
10,996
Posted By Corona688
Quote it too. egrep -F "R1_980302_105147(2)"...
Quote it too.

egrep -F "R1_980302_105147(2)" namelist.txt
10,996
Posted By in2nix4life
You can also try this method eliminating the use...
You can also try this method eliminating the use of the cat command and making sure to include quotes around the $line variable.


while read line
do
echo "$line"
blah blah "$line"...
10,996
Posted By Corona688
That won't work either. That will make it all...
That won't work either. That will make it all one giant filename instead of a list of files!

The problem isn't how you're using the for-loop, the problem is you're using backticks to shoehorn a...
10,996
Posted By thegeek
try this way ( doublequotes ) for F in...
try this way ( doublequotes )

for F in "$FILES"
3,130
Posted By Scrutinizer
For completeness, here is the sed command: sed...
For completeness, here is the sed command:
sed 's/..//' file
3,130
Posted By bartus11
You don't need sed for such a simple task: cut...
You don't need sed for such a simple task: cut -c3- file
Showing results 1 to 25 of 25

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