06-15-2013
Quote:
Originally Posted by
somu_june
I tried with awk command
head -10 /home/o55555/test11.txt | awk -F '/' '{print $0\%/*","$NF}' .
But I got below error Syntax Error The source line is 1.
The error context is
{print >>> $0\ <<< %/*","$NF}
awk: 0602-502 The statement cannot be correctly parsed. The source line is 1.
and the file has the data like I mentioned in my early post
/dev/cm/test1.txt
/qa/tm/hmkr/cc/test2.txt
Can we get above result using awk command
You can get the above result for this exact input. But, to get a reliable solution we need more details about what the what forms of pathnames can exist in your input file, what shell you're using, and whether or not your environment supports a super root file system.
If the contents of your input file only contains absolute pathnames, never contains the pathname "/", and either your environment doesn't support a super root or your input file will never contain the pathname of a file in your root directory; then the solution Scott proposed will work and can be translated into awk code if you really need something much less efficient.
If your input contains any relative pathnames that don't contain a / character, we need a completely different approach.
If your environment includes a super root (where //
node refers to the root of the system named
node on your local network), there is another set of issues that need to be considered before we can propose an approach that will work reliably.
So, instead of giving us a two line example of what the input might look like, please give us an explicit description of the allowed input file format.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Oracle procedure create files on UNIX folder on a regular basis. I need to FTP files onto windows server and place the files, based on their name, in the corresponding folders. File name is as follows: ccyymmddfoldernamefile.txt; Folder Name length could be of any size; however, the prefix and... (3 Replies)
Discussion started by: MeganP
3 Replies
2. Shell Programming and Scripting
Hi,
I have a requirement to move a file from one folder(a) to another folder(b) only when folder (b) have a write permission. Folder permission is 755
If the permission is otherthan 755 we need to come out of the loop
I will appreciate your help
Thanks
Soll (1 Reply)
Discussion started by: sollins
1 Replies
3. Shell Programming and Scripting
This is the file structure:
DESKTOP/Root of Photo Folders/Folder1qweqwasdfsd/*jpg
DESKTOP/Root of Photo Folders/Folder2asdasdasd/*jpg
DESKTOP/Root of Photo Folders/Folder3asdadfhgasdf/*jpg
DESKTOP/Root of Photo Folders/Folder4qwetwdfsdfg/*jpg
DESKTOP/Root of Photo... (4 Replies)
Discussion started by: guptaxpn
4 Replies
4. Shell Programming and Scripting
Hi,
I have a string like ABC.123.XYZ-A1-B2-P1-C4. I want to delimit the string based on "-" and then get result as only two strings. One with string till last hyphen and other with value after last hyphen... For this case, it would be something like first string as "ABC.123.XYZ-A1-B2-P1" and... (6 Replies)
Discussion started by: gupt_ash
6 Replies
5. Shell Programming and Scripting
Hi all,
let me explain my requirments
i am having 5 folder with different name for eg) abc , cdf , efd, rtg, ead
each 5 folders contain 15 files
i want to move 10 files to some other folder, remain 5 files should be there in the same folder.
give me some suggestion on this. (6 Replies)
Discussion started by: natraj005
6 Replies
6. Shell Programming and Scripting
Hello,
I am trying to find the record count in a specific folder,
Here is the part of the code
===========================
STARTDATE=`date +"%y%m%d%H%M"`
for i in `ls *.DAT`
do
wc -l $i >> /XYZ/SrcFiles/"Record_counts"$STARTDATE.csv
... (2 Replies)
Discussion started by: Shanks
2 Replies
7. Shell Programming and Scripting
Hi all,
I have a number of strings like below:
//mnt/autocor/43°13'(33")W/
and i'm trying to get the numbers in this string, for example
431333
please help
thanks ahead (14 Replies)
Discussion started by: sunnydanniel
14 Replies
8. UNIX for Advanced & Expert Users
Hi All,
I woul like to know with out opening a file in unix ,how we can find out what is the delemeter in that file...
Thanks..
edit by bakunin: changed thread title to "delimiter" so it can be found. (4 Replies)
Discussion started by: raju4u
4 Replies
9. Shell Programming and Scripting
Hi,
I have a No Delimiter variable length text file with following schema -
Column Name Data length
Firstname 5
Lastname 5
age 3
phoneno1 10
phoneno2 10
phoneno3 10
sample data - ... (16 Replies)
Discussion started by: Gaurav Martha
16 Replies
10. Shell Programming and Scripting
Hi,
Extremely new to Perl scripting, but need a quick fix without using TEXT::CSV
I need to read in a file, pass any delimiter as an argument, and convert it to bar delimited on the output. In addition, enclose fields within double quotes in case of any embedded delimiters.
Any help would... (2 Replies)
Discussion started by: JPB1977
2 Replies
next(1) General Commands Manual next(1)
NAME
next - show the next message (only available within the message handling system, mh)
SYNOPSIS
next [+foldername] [-[no]header] [-help] [-showproc program] [-noshowproc] [options to showproc]
OPTIONS
Displays a one-line header before the message. The header consists of the name of the folder and the message number. This is the default
behavior. It can be suppressed with the -noheader option. Prints a list of the valid options to this command. Specifies an alternative
program to list messages. The default is to use the program defined by the showproc: entry in the file. As with show, you can give options
to the showproc program at the command line. These are passed directly to showproc by next. (If you specify an option that has a numerical
value, leave no space between the argument and the value. See RESTRICTIONS for more information.)
The defaults for this command are:
+folder defaults to the current folder -header
DESCRIPTION
The command next displays the next message in the current folder. The next message is the one after the current message in the folder. The
message that is shown becomes the current message.
If you name a folder using the +folder argument, next displays the next message in the folder you specify. That folder becomes the current
folder.
RESTRICTIONS
The next command is really a link to the show program. As a result, if you make a link to next and that link is not called next, your link
will act like show instead. To avoid this, add a profile-entry for the link to your and add the argument next to the entry.
Also, if you use the showproc switch to specify an alternative viewer, leave no space between the options specified with the viewer and
their values. For example, if you want to use the more command to scroll through messages in your inbox folder, and you want to pause every
five lines, you would enter the following command, where there is no space between the option n and the value 5: % next +inbox -showproc
more -n5
If there is space between the option n and the value 5, the command interprets 5 as a message number to view.
PROFILE COMPONENTS
Path: To determine the user's Mail directory
showproc: Program to show the message
FILES
The user profile.
SEE ALSO
show(1), prev(1), mh_profile(4)
next(1)